OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /// Unit tests for doc. | 5 /// Unit tests for doc. |
6 library dartdocTests; | 6 library dartdocTests; |
7 | 7 |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import 'dart:io'; | 9 import 'dart:io'; |
10 | 10 |
11 import 'package:pathos/path.dart' as path; | 11 import 'package:pathos/path.dart' as path; |
12 import 'package:unittest/unittest.dart'; | 12 import 'package:unittest/unittest.dart'; |
13 | 13 |
14 // TODO(rnystrom): Use "package:" URL (#4968). | 14 // TODO(rnystrom): Use "package:" URL (#4968). |
15 import '../lib/dartdoc.dart' as dd; | 15 import '../lib/dartdoc.dart' as dd; |
16 import '../lib/markdown.dart'; | 16 import '../lib/markdown.dart'; |
17 import 'markdown_test.dart'; | 17 import 'markdown_test.dart'; |
18 | 18 |
19 main() { | 19 main() { |
20 group('countOccurrences', () { | |
21 test('empty text returns 0', () { | |
22 expect(dd.countOccurrences('', 'needle'), equals(0)); | |
23 }); | |
24 | |
25 test('one occurrence', () { | |
26 expect(dd.countOccurrences('bananarama', 'nara'), equals(1)); | |
27 }); | |
28 | |
29 test('multiple occurrences', () { | |
30 expect(dd.countOccurrences('bananarama', 'a'), equals(5)); | |
31 }); | |
32 | |
33 test('overlapping matches do not count', () { | |
34 expect(dd.countOccurrences('bananarama', 'ana'), equals(1)); | |
35 }); | |
36 }); | |
37 | |
38 group('repeat', () { | |
39 test('zero times returns an empty string', () { | |
40 expect(dd.repeat('ba', 0), isEmpty); | |
41 }); | |
42 | |
43 test('one time returns the string', () { | |
44 expect(dd.repeat('ba', 1), equals('ba')); | |
45 }); | |
46 | |
47 test('multiple times', () { | |
48 expect(dd.repeat('ba', 3), equals('bababa')); | |
49 }); | |
50 | |
51 test('multiple times with a separator', () { | |
52 expect(dd.repeat('ba', 3, separator: ' '), equals('ba ba ba')); | |
53 }); | |
54 }); | |
55 | |
56 group('isAbsolute', () { | 20 group('isAbsolute', () { |
57 final doc = new dd.Dartdoc(); | 21 final doc = new dd.Dartdoc(); |
58 | 22 |
59 test('returns false if there is no scheme', () { | 23 test('returns false if there is no scheme', () { |
60 expect(doc.isAbsolute('index.html'), isFalse); | 24 expect(doc.isAbsolute('index.html'), isFalse); |
61 expect(doc.isAbsolute('foo/index.html'), isFalse); | 25 expect(doc.isAbsolute('foo/index.html'), isFalse); |
62 expect(doc.isAbsolute('foo/bar/index.html'), isFalse); | 26 expect(doc.isAbsolute('foo/bar/index.html'), isFalse); |
63 }); | 27 }); |
64 | 28 |
65 test('returns true if there is a scheme', () { | 29 test('returns true if there is a scheme', () { |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 } | 273 } |
310 } | 274 } |
311 | 275 |
312 | 276 |
313 validateDartdocMarkdown(String description, String markdown, | 277 validateDartdocMarkdown(String description, String markdown, |
314 String html) { | 278 String html) { |
315 var dartdoc = new dd.Dartdoc(); | 279 var dartdoc = new dd.Dartdoc(); |
316 validate(description, markdown, html, linkResolver: dartdoc.dartdocResolver, | 280 validate(description, markdown, html, linkResolver: dartdoc.dartdocResolver, |
317 inlineSyntaxes: dartdoc.dartdocSyntaxes); | 281 inlineSyntaxes: dartdoc.dartdocSyntaxes); |
318 } | 282 } |
OLD | NEW |