Fix TS errors

This commit is contained in:
Mason Malone
2022-11-19 13:01:21 -08:00
parent 3316aa5f4f
commit 1b201bf462
2 changed files with 4 additions and 4 deletions

View File

@@ -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) {

View File

@@ -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'
); );
}); });