|
1 |
| -import { describe, it } from "node:test"; |
| 1 | +import { describe, it, before } from "node:test"; |
2 | 2 | import assert from "node:assert";
|
3 | 3 | import { DocGen } from '../src/doc-gen';
|
| 4 | +import { ParserContext } from "@microsoft/tsdoc"; |
4 | 5 |
|
5 | 6 | describe('DocGen', () => {
|
6 |
| - it('should parse a typescript file and return a ParserContext', async () => { |
7 |
| - const docGen = new DocGen(); |
8 |
| - const result = await docGen.parseDoc('./test/fixtures/my-circle.ts'); |
9 |
| - assert.ok(result, 'ParserContext should be returned'); |
| 7 | + let docGen: DocGen; |
| 8 | + let context: ParserContext; |
| 9 | + |
| 10 | + before(async () => { |
| 11 | + docGen = new DocGen('my-circle'); |
| 12 | + context = await docGen.parseDoc('./test/fixtures/my-circle.ts'); |
| 13 | + }); |
| 14 | + |
| 15 | + it('should parse a typescript file and return a ParserContext', () => { |
| 16 | + assert.ok(context, 'ParserContext should be returned'); |
10 | 17 | });
|
11 | 18 |
|
12 |
| - it('returns the demo tag', async () => { |
13 |
| - const docGen = new DocGen(); |
14 |
| - const result = await docGen.parseDoc('./test/fixtures/my-circle.ts'); |
15 |
| - assert.equal(result.docComment.customBlocks.length, 1); |
| 19 | + it('returns the demo tag', () => { |
| 20 | + assert.equal(context.docComment.customBlocks.length, 1); |
16 | 21 | });
|
17 | 22 |
|
18 |
| - it('rendered result contains tag', async () => { |
19 |
| - const docGen = new DocGen(); |
20 |
| - const result = await docGen.parseDoc('./test/fixtures/my-circle.ts'); |
21 |
| - const doc = docGen.renderDocs(result); |
| 23 | + it('rendered result contains tag', () => { |
| 24 | + const doc = docGen.renderDocs(context); |
22 | 25 | assert.match(doc, /my-circle/);
|
23 | 26 | });
|
| 27 | + |
| 28 | + describe('getters', () => { |
| 29 | + |
| 30 | + it('returns correct path for default tag', () => { |
| 31 | + assert.equal(docGen.src, './dist/my-circle.js'); |
| 32 | + }); |
| 33 | + |
| 34 | + it('returns correct path for custom tag', () => { |
| 35 | + const customDocGen = new DocGen('custom-element'); |
| 36 | + assert.equal(customDocGen.src, './dist/custom-element.js'); |
| 37 | + }); |
| 38 | + it('returns formatted title for default tag', () => { |
| 39 | + assert.equal(docGen.title, '<my-circle> Component Demo'); |
| 40 | + }); |
| 41 | + |
| 42 | + it('returns formatted title for custom tag', () => { |
| 43 | + const customDocGen = new DocGen('custom-element'); |
| 44 | + assert.equal(customDocGen.title, '<custom-element> Component Demo'); |
| 45 | + }); |
| 46 | + }); |
24 | 47 | });
|
0 commit comments