@@ -12,6 +12,7 @@ import 'package:dartdoc/src/model.dart';
1212import 'package:dartdoc/src/model_utils.dart' ;
1313import 'package:dartdoc/src/package_meta.dart' ;
1414import 'package:test/test.dart' ;
15+ import 'package:path/path.dart' as p;
1516
1617import 'src/utils.dart' as utils;
1718
@@ -805,6 +806,7 @@ void main() {
805806 });
806807
807808 test ('has source code' , () {
809+ initializeConfig (addCrossdart: false );
808810 expect (topLevelFunction.sourceCode, startsWith ('@deprecated' ));
809811 expect (topLevelFunction.sourceCode, endsWith ('''
810812String topLevelFunction(int param1, bool param2, Cool coolBeans,
@@ -844,6 +846,13 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
844846 .singleWhere ((m) => m.name == 'convertToMap' );
845847 });
846848
849+ tearDown (() {
850+ var file = new File (p.join (Directory .current.path, "crossdart.json" ));
851+ if (file.existsSync ()) {
852+ file.deleteSync ();
853+ }
854+ });
855+
847856 test ('has a fully qualified name' , () {
848857 expect (m1.fullyQualifiedName, 'ex.B.m1' );
849858 });
@@ -920,7 +929,22 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
920929 });
921930
922931 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;" );
924948 });
925949
926950 group (".crossdartHtmlTag()" , () {
@@ -929,7 +953,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
929953 String packageName = m1.library.package.name;
930954 String packageVersion = m1.library.package.version;
931955 expect (m1.crossdartHtmlTag,
932- contains ("//crossdart.info/p/$packageName /$packageVersion " ));
956+ contains ("//www. crossdart.info/p/$packageName /$packageVersion " ));
933957 });
934958
935959 test ('it returns an empty string when Crossdart support is disabled' , () {
0 commit comments