| OLD | NEW |
| 1 import 'dart:convert'; | 1 import 'dart:convert'; |
| 2 import 'dart:io'; | 2 import 'dart:io'; |
| 3 | 3 |
| 4 import 'package:path/path.dart' as p; | 4 import 'package:path/path.dart' as p; |
| 5 import 'package:scheduled_test/descriptor.dart' as d; | 5 import 'package:scheduled_test/descriptor.dart' as d; |
| 6 import 'package:scheduled_test/scheduled_test.dart'; | 6 import 'package:scheduled_test/scheduled_test.dart'; |
| 7 import 'package:unittest/matcher.dart'; | 7 import 'package:unittest/matcher.dart'; |
| 8 | 8 |
| 9 import 'util.dart'; | 9 import 'util.dart'; |
| 10 import '../lib/docgen.dart' as dg; | 10 import '../lib/docgen.dart' as dg; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 currentSchedule.onComplete.schedule(() { | 25 currentSchedule.onComplete.schedule(() { |
| 26 d.defaultRoot = null; | 26 d.defaultRoot = null; |
| 27 return tempDir.delete(recursive: true); | 27 return tempDir.delete(recursive: true); |
| 28 }); | 28 }); |
| 29 }); | 29 }); |
| 30 | 30 |
| 31 test('json output', () { | 31 test('json output', () { |
| 32 schedule(() { | 32 schedule(() { |
| 33 var codeDir = getMultiLibraryCodePath(); | 33 var codeDir = getMultiLibraryCodePath(); |
| 34 expect(FileSystemEntity.isDirectorySync(codeDir), isTrue); | 34 expect(FileSystemEntity.isDirectorySync(codeDir), isTrue); |
| 35 return dg.docgen(['$codeDir/'], out: p.join(d.defaultRoot, 'docs')); | 35 return dg.docgen([codeDir], out: p.join(d.defaultRoot, 'docs')); |
| 36 }); | 36 }); |
| 37 | 37 |
| 38 d.dir('docs', [ | 38 d.dir('docs', [ |
| 39 d.matcherFile('index.json', _isJsonMap), | 39 d.matcherFile('index.json', _isJsonMap), |
| 40 d.matcherFile('index.txt', _hasSortedLines), | 40 d.matcherFile('index.txt', _hasSortedLines), |
| 41 d.matcherFile('library_list.json', _isJsonMap), | 41 d.matcherFile('library_list.json', _isJsonMap), |
| 42 d.matcherFile('test_lib-bar.C.json', _isJsonMap), | 42 d.matcherFile('test_lib-bar.C.json', _isJsonMap), |
| 43 d.matcherFile('test_lib-bar.json', _isJsonMap), | 43 d.matcherFile('test_lib-bar.json', _isJsonMap), |
| 44 d.matcherFile('test_lib-foo.B.json', _isJsonMap), | 44 d.matcherFile('test_lib-foo.B.json', _isJsonMap), |
| 45 d.matcherFile('test_lib-foo.json', _isJsonMap), | 45 d.matcherFile('test_lib-foo.json', _isJsonMap), |
| 46 d.matcherFile('test_lib.A.json', _isJsonMap), | 46 d.matcherFile('test_lib.A.json', _isJsonMap), |
| 47 d.matcherFile('test_lib.B.json', _isJsonMap), | 47 d.matcherFile('test_lib.B.json', _isJsonMap), |
| 48 d.matcherFile('test_lib.C.json', _isJsonMap), | 48 d.matcherFile('test_lib.C.json', _isJsonMap), |
| 49 d.matcherFile('test_lib.json', _isJsonMap), | 49 d.matcherFile('test_lib.json', _isJsonMap), |
| 50 ]).validate(); | 50 ]).validate(); |
| 51 | 51 |
| 52 }); | 52 }); |
| 53 | 53 |
| 54 test('typedef gen', () { | 54 test('typedef gen', () { |
| 55 schedule(() { | 55 schedule(() { |
| 56 var codeDir = getMultiLibraryCodePath(); | 56 var codeDir = getMultiLibraryCodePath(); |
| 57 expect(FileSystemEntity.isDirectorySync(codeDir), isTrue); | 57 expect(FileSystemEntity.isDirectorySync(codeDir), isTrue); |
| 58 return dg.docgen(['$codeDir/'], out: p.join(d.defaultRoot, 'docs')); | 58 return dg.docgen([codeDir], out: p.join(d.defaultRoot, 'docs')); |
| 59 }); | 59 }); |
| 60 | 60 |
| 61 schedule(() { | 61 schedule(() { |
| 62 var path = p.join(d.defaultRoot, 'docs', 'test_lib-bar.json'); | 62 var path = p.join(d.defaultRoot, 'docs', 'test_lib-bar.json'); |
| 63 var dartCoreJson = new File(path).readAsStringSync(); | 63 var dartCoreJson = new File(path).readAsStringSync(); |
| 64 | 64 |
| 65 var testLibBar = JSON.decode(dartCoreJson) as Map<String, dynamic>; | 65 var testLibBar = JSON.decode(dartCoreJson) as Map<String, dynamic>; |
| 66 | 66 |
| 67 // | 67 // |
| 68 // Validate function doc references | 68 // Validate function doc references |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 return orderedMatcher.matches(lines, {}); | 104 return orderedMatcher.matches(lines, {}); |
| 105 }, 'String has sorted lines'); | 105 }, 'String has sorted lines'); |
| 106 | 106 |
| 107 final Matcher _isJsonMap = predicate((input) { | 107 final Matcher _isJsonMap = predicate((input) { |
| 108 try { | 108 try { |
| 109 return JSON.decode(input) is Map; | 109 return JSON.decode(input) is Map; |
| 110 } catch (e) { | 110 } catch (e) { |
| 111 return false; | 111 return false; |
| 112 } | 112 } |
| 113 }, 'Output is JSON encoded Map'); | 113 }, 'Output is JSON encoded Map'); |
| OLD | NEW |