-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(banira): refactor doc page generation interfaces
- Loading branch information
Sebastian Schürmann
committed
Jan 3, 2025
1 parent
61e16a7
commit 292de16
Showing
4 changed files
with
56 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,47 @@ | ||
import { describe, it } from "node:test"; | ||
import { describe, it, before } from "node:test"; | ||
import assert from "node:assert"; | ||
import { DocGen } from '../src/doc-gen'; | ||
import { ParserContext } from "@microsoft/tsdoc"; | ||
|
||
describe('DocGen', () => { | ||
it('should parse a typescript file and return a ParserContext', async () => { | ||
const docGen = new DocGen(); | ||
const result = await docGen.parseDoc('./test/fixtures/my-circle.ts'); | ||
assert.ok(result, 'ParserContext should be returned'); | ||
let docGen: DocGen; | ||
let context: ParserContext; | ||
|
||
before(async () => { | ||
docGen = new DocGen('my-circle'); | ||
context = await docGen.parseDoc('./test/fixtures/my-circle.ts'); | ||
}); | ||
|
||
it('should parse a typescript file and return a ParserContext', () => { | ||
assert.ok(context, 'ParserContext should be returned'); | ||
}); | ||
|
||
it('returns the demo tag', async () => { | ||
const docGen = new DocGen(); | ||
const result = await docGen.parseDoc('./test/fixtures/my-circle.ts'); | ||
assert.equal(result.docComment.customBlocks.length, 1); | ||
it('returns the demo tag', () => { | ||
assert.equal(context.docComment.customBlocks.length, 1); | ||
}); | ||
|
||
it('rendered result contains tag', async () => { | ||
const docGen = new DocGen(); | ||
const result = await docGen.parseDoc('./test/fixtures/my-circle.ts'); | ||
const doc = docGen.renderDocs(result); | ||
it('rendered result contains tag', () => { | ||
const doc = docGen.renderDocs(context); | ||
assert.match(doc, /my-circle/); | ||
}); | ||
|
||
describe('getters', () => { | ||
|
||
it('returns correct path for default tag', () => { | ||
assert.equal(docGen.src, './dist/my-circle.js'); | ||
}); | ||
|
||
it('returns correct path for custom tag', () => { | ||
const customDocGen = new DocGen('custom-element'); | ||
assert.equal(customDocGen.src, './dist/custom-element.js'); | ||
}); | ||
it('returns formatted title for default tag', () => { | ||
assert.equal(docGen.title, '<my-circle> Component Demo'); | ||
}); | ||
|
||
it('returns formatted title for custom tag', () => { | ||
const customDocGen = new DocGen('custom-element'); | ||
assert.equal(customDocGen.title, '<custom-element> Component Demo'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters