Skip to content

Commit 399dd96

Browse files
committed
Add some tests
Only enough to mirror the few tests we have that exercise the existing renderers. In the future, we should have a more comprehensive suite that covers both html and md.
1 parent bc983d9 commit 399dd96

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

test/model_test.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ void main() {
373373
equals(utils.kTestPackagePublicLibraries - 5));
374374
});
375375

376+
// TODO consider moving these to a separate suite
376377
test('CategoryRendererHtml renders category label', () {
377378
Category category = packageGraph.publicPackages.first.categories.first;
378379
CategoryRendererHtml renderer = CategoryRendererHtml();
@@ -388,6 +389,21 @@ void main() {
388389
expect(renderer.renderLinkedName(category),
389390
'<a href="${HTMLBASE_PLACEHOLDER}topics/Superb-topic.html">Superb</a>');
390391
});
392+
393+
test('CategoryRendererMd renders category label', () {
394+
Category category = packageGraph.publicPackages.first.categories.first;
395+
CategoryRendererMd renderer = CategoryRendererMd();
396+
expect(
397+
renderer.renderCategoryLabel(category),
398+
'[Superb](${HTMLBASE_PLACEHOLDER}topics/Superb-topic.html)');
399+
});
400+
401+
test('CategoryRendererMd renders linkedName', () {
402+
Category category = packageGraph.publicPackages.first.categories.first;
403+
CategoryRendererMd renderer = CategoryRendererMd();
404+
expect(renderer.renderLinkedName(category),
405+
'[Superb](${HTMLBASE_PLACEHOLDER}topics/Superb-topic.html)');
406+
});
391407
});
392408

393409
group('LibraryContainer', () {

test/html/html_template_renderer_test.dart renamed to test/render/template_renderer_test.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,22 @@ void main() {
2323
expect(test, equals('<span class="deprecated">Banana</span> Fruit'));
2424
});
2525
});
26+
27+
group('MdTemplateRenderer', () {
28+
MdTemplateRenderer renderer;
29+
30+
setUpAll(() {
31+
renderer = MdTemplateRenderer();
32+
});
33+
34+
test('composeLayoutTitle', () {
35+
String test = renderer.composeLayoutTitle('Banana', 'Fruit', false);
36+
expect(test, equals('Banana Fruit'));
37+
});
38+
39+
test('composeLayoutTitle deprecated', () {
40+
String test = renderer.composeLayoutTitle('Banana', 'Fruit', true);
41+
expect(test, equals('~~Banana~~ Fruit'));
42+
});
43+
});
2644
}

0 commit comments

Comments
 (0)