@@ -12,6 +12,7 @@ import 'package:dartdoc/src/model.dart';
12
12
import 'package:dartdoc/src/model_utils.dart' ;
13
13
import 'package:dartdoc/src/package_meta.dart' ;
14
14
import 'package:test/test.dart' ;
15
+ import 'package:path/path.dart' as p;
15
16
16
17
import 'src/utils.dart' as utils;
17
18
@@ -805,6 +806,7 @@ void main() {
805
806
});
806
807
807
808
test ('has source code' , () {
809
+ initializeConfig (addCrossdart: false );
808
810
expect (topLevelFunction.sourceCode, startsWith ('@deprecated' ));
809
811
expect (topLevelFunction.sourceCode, endsWith ('''
810
812
String topLevelFunction(int param1, bool param2, Cool coolBeans,
@@ -844,6 +846,13 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
844
846
.singleWhere ((m) => m.name == 'convertToMap' );
845
847
});
846
848
849
+ tearDown (() {
850
+ var file = new File (p.join (Directory .current.path, "crossdart.json" ));
851
+ if (file.existsSync ()) {
852
+ file.deleteSync ();
853
+ }
854
+ });
855
+
847
856
test ('has a fully qualified name' , () {
848
857
expect (m1.fullyQualifiedName, 'ex.B.m1' );
849
858
});
@@ -920,7 +929,22 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
920
929
});
921
930
922
931
test ('method source code indents correctly' , () {
923
- expect (convertToMap.sourceCode, 'Map<X, Y> convertToMap() => null;' );
932
+ initializeConfig (addCrossdart: false );
933
+ expect (convertToMap.sourceCode,
934
+ 'Map<X, Y> convertToMap() => null;' );
935
+ });
936
+
937
+ test ('method source code crossdartifies correctly' , () {
938
+ convertToMap.clearSourceCodeCache ();
939
+ new File (p.join (Directory .current.path, "crossdart.json" ))
940
+ .writeAsStringSync ("""
941
+ {"testing/test_package/lib/fake.dart":
942
+ {"references":[{"offset":5806,"end":5809,"remotePath":"http://www.example.com/fake.dart"}]}}
943
+ """ );
944
+
945
+ initializeConfig (addCrossdart: true , inputDir: Directory .current);
946
+ expect (convertToMap.sourceCode,
947
+ "<a class='crossdart-link' href='http://www.example.com/fake.dart'>Map</a><X, Y> convertToMap() => null;" );
924
948
});
925
949
926
950
group (".crossdartHtmlTag()" , () {
@@ -929,7 +953,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
929
953
String packageName = m1.library.package.name;
930
954
String packageVersion = m1.library.package.version;
931
955
expect (m1.crossdartHtmlTag,
932
- contains ("//crossdart.info/p/$packageName /$packageVersion " ));
956
+ contains ("//www. crossdart.info/p/$packageName /$packageVersion " ));
933
957
});
934
958
935
959
test ('it returns an empty string when Crossdart support is disabled' , () {
0 commit comments