Skip to content

Commit 1250b18

Browse files
committed
lots more tests
1 parent dea14d4 commit 1250b18

File tree

2 files changed

+85
-2
lines changed

2 files changed

+85
-2
lines changed

test/model_test.dart

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ void main() {
168168
TopLevelVariable testingCodeSyntaxInOneLiners;
169169

170170
Class specialList;
171+
Class baseForDocComments;
172+
Method doAwesomeStuff;
171173
Class subForDocComments;
172174

173175
ModelFunction short;
@@ -196,9 +198,72 @@ void main() {
196198
subForDocComments =
197199
fakeLibrary.classes.firstWhere((c) => c.name == 'SubForDocComments');
198200

201+
baseForDocComments =
202+
fakeLibrary.classes.firstWhere((c) => c.name == 'BaseForDocComments');
203+
doAwesomeStuff = baseForDocComments.instanceMethods
204+
.firstWhere((m) => m.name == 'doAwesomeStuff');
205+
199206
short = fakeLibrary.functions.firstWhere((f) => f.name == 'short');
200207
});
201208

209+
group('doc references', () {
210+
String docsAsHtml;
211+
212+
setUp(() {
213+
docsAsHtml = doAwesomeStuff.documentationAsHtml;
214+
});
215+
216+
test('codeifies a class from the SDK', () {
217+
expect(docsAsHtml,
218+
contains('<code class="prettyprint lang-dart">String</code>'));
219+
});
220+
221+
test('codeifies a reference to its parameter', () {
222+
expect(docsAsHtml,
223+
contains('<code class="prettyprint lang-dart">value</code>'));
224+
});
225+
226+
test('links to a reference to its class', () {
227+
expect(docsAsHtml, contains(
228+
'<a href="fake/BaseForDocComments-class.html">BaseForDocComments</a>'));
229+
});
230+
231+
test('links to a reference to a top-level const', () {
232+
expect(
233+
docsAsHtml, contains('<a href="">NAME_WITH_TWO_UNDERSCORES</a>'));
234+
});
235+
236+
test('links to a method in this class', () {
237+
expect(docsAsHtml, contains(
238+
'<a href="fake/BaseForDocComments/anotherMethod.html">anotherMethod</a>'));
239+
});
240+
241+
test('links to a top-level function in this library', () {
242+
expect(docsAsHtml, contains(
243+
'<a href="fake/topLevelFunction.html">topLevelFunction</a>'));
244+
});
245+
246+
test('links to top-level function from an imported library', () {
247+
expect(
248+
docsAsHtml, contains('<a href="ex/function1.html">function1</a>'));
249+
});
250+
251+
test('links to a class from an imported lib', () {
252+
expect(docsAsHtml, contains('<a href="ex/Apple-class.html">Apple</a>'));
253+
});
254+
255+
test('links to a top-level const from an imported lib', () {
256+
expect(docsAsHtml, contains(
257+
'<a href="fake/incorrectDocReference.html">incorrectDocReference</a>'));
258+
});
259+
260+
test('links to a top-level variable with a prefix from an imported lib',
261+
() {
262+
expect(docsAsHtml,
263+
contains('<a href="">css.theOnlyThingInTheLibrary</a>'));
264+
});
265+
});
266+
202267
test('multi-underscore names in brackets do not become italicized', () {
203268
expect(short.documentation, contains('[NAME_WITH_TWO_UNDERSCORES]'));
204269
expect(short.documentation, contains('[NAME_SINGLEUNDERSCORE]'));

test_package/lib/fake.dart

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ import 'dart:collection';
4646

4747
import 'example.dart';
4848

49+
import 'css.dart' as css;
50+
4951
/// Useful for annotations.
5052
class Annotation {
5153
final String value;
@@ -384,10 +386,26 @@ class ExtraSpecialList<E> extends SpecialList {}
384386
class BaseForDocComments {
385387
/// Takes a [value] and returns a String.
386388
///
387-
/// This methods is inside of [BaseForDocComments]
389+
/// This methods is inside of [BaseForDocComments] class
390+
///
391+
/// Also [NAME_WITH_TWO_UNDERSCORES] which is a top-level const
392+
///
393+
/// Returns a [String]
394+
///
395+
/// Reference to another method in this class [anotherMethod]
396+
///
397+
/// Reference to a top-level function in this library [topLevelFunction]
388398
///
389-
/// Also [NAME_WITH_TWO_UNDERSCORES]
399+
/// Reference to a top-level function in another library (example lib) [function1]
400+
///
401+
/// Reference to a class in example lib [Apple]
402+
///
403+
/// Reference to a top-level const in another library [incorrectDocReference]
404+
///
405+
/// Reference to prefixed-name from another lib [css.theOnlyThingInTheLibrary]
390406
String doAwesomeStuff(int value) => null;
407+
408+
void anotherMethod() {}
391409
}
392410

393411
/// Testing if docs for inherited method are correct.

0 commit comments

Comments
 (0)