mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-13 20:39:38 +02:00
Fix TS errors
This commit is contained in:
@@ -56,7 +56,7 @@ export class Diagram {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
text = text + '\n';
|
text = text + '\n';
|
||||||
this.db.clear();
|
this.db.clear?.();
|
||||||
this.parser.parse(text);
|
this.parser.parse(text);
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@@ -5,12 +5,12 @@ const dbMock = () => ({ setDiagramTitle: vi.fn() });
|
|||||||
|
|
||||||
describe('extractFrontmatter', () => {
|
describe('extractFrontmatter', () => {
|
||||||
it('returns text unchanged if no frontmatter', () => {
|
it('returns text unchanged if no frontmatter', () => {
|
||||||
expect(extractFrontMatter('diagram', null)).toEqual('diagram');
|
expect(extractFrontMatter('diagram', dbMock())).toEqual('diagram');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns text unchanged if frontmatter lacks closing delimiter', () => {
|
it('returns text unchanged if frontmatter lacks closing delimiter', () => {
|
||||||
const text = `---\ntitle: foo\ndiagram`;
|
const text = `---\ntitle: foo\ndiagram`;
|
||||||
expect(extractFrontMatter(text, null)).toEqual(text);
|
expect(extractFrontMatter(text, dbMock())).toEqual(text);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handles empty frontmatter', () => {
|
it('handles empty frontmatter', () => {
|
||||||
@@ -71,7 +71,7 @@ describe('extractFrontmatter', () => {
|
|||||||
|
|
||||||
it('throws exception for invalid YAML syntax', () => {
|
it('throws exception for invalid YAML syntax', () => {
|
||||||
const text = `---\n!!!\n---\ndiagram`;
|
const text = `---\n!!!\n---\ndiagram`;
|
||||||
expect(() => extractFrontMatter(text, null)).toThrow(
|
expect(() => extractFrontMatter(text, dbMock())).toThrow(
|
||||||
'tag suffix cannot contain exclamation marks'
|
'tag suffix cannot contain exclamation marks'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user