Skip to content

Commit

Permalink
test: Add packet and xychart into mermaidAPI test
Browse files Browse the repository at this point in the history
  • Loading branch information
sidharthv96 committed Nov 16, 2023
1 parent a8105f0 commit bca645f
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions packages/mermaid/src/mermaidAPI.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
'use strict';
import { vi } from 'vitest';

// -------------------------------------
Expand Down Expand Up @@ -27,26 +26,26 @@ vi.mock('./diagrams/git/gitGraphRenderer.js');
vi.mock('./diagrams/gantt/ganttRenderer.js');
vi.mock('./diagrams/user-journey/journeyRenderer.js');
vi.mock('./diagrams/pie/pieRenderer.js');
vi.mock('./diagrams/packet/renderer.js');
vi.mock('./diagrams/xychart/xychartRenderer.js');
vi.mock('./diagrams/requirement/requirementRenderer.js');
vi.mock('./diagrams/sequence/sequenceRenderer.js');
vi.mock('./diagrams/state/stateRenderer-v2.js');

// -------------------------------------

import mermaid from './mermaid.js';
import assignWithDepth from './assignWithDepth.js';
import type { MermaidConfig } from './config.type.js';

import mermaidAPI, { removeExistingElements } from './mermaidAPI.js';
import {
createCssStyles,
createUserStyles,
import mermaid from './mermaid.js';
import mermaidAPI, {
appendDivSvgG,
cleanUpSvgCode,
createCssStyles,
createUserStyles,
putIntoIFrame,
removeExistingElements,
} from './mermaidAPI.js';

import assignWithDepth from './assignWithDepth.js';

// --------------
// Mocks
// To mock a module, first define a mock for it, then (if used explicitly in the tests) import it. Be sure the path points to exactly the same file as is imported in mermaidAPI (the module being tested)
Expand All @@ -56,6 +55,7 @@ vi.mock('./styles.js', () => {
default: vi.fn().mockReturnValue(' .userStyle { font-weight:bold; }'),
};
});

import getStyles from './styles.js';

vi.mock('stylis', () => {
Expand All @@ -65,6 +65,7 @@ vi.mock('stylis', () => {
serialize: vi.fn().mockReturnValue('stylis serialized css'),
};
});

import { compile, serialize } from 'stylis';
import { decodeEntities, encodeEntities } from './utils.js';

Expand Down Expand Up @@ -714,6 +715,8 @@ describe('mermaidAPI', () => {
{ textDiagramType: 'gantt', expectedType: 'gantt' },
{ textDiagramType: 'journey', expectedType: 'journey' },
{ textDiagramType: 'pie', expectedType: 'pie' },
{ textDiagramType: 'packet-beta', expectedType: 'packet' },
{ textDiagramType: 'xychart-beta', expectedType: 'xychart' },
{ textDiagramType: 'requirementDiagram', expectedType: 'requirement' },
{ textDiagramType: 'sequenceDiagram', expectedType: 'sequence' },
{ textDiagramType: 'stateDiagram-v2', expectedType: 'stateDiagram' },
Expand Down

0 comments on commit bca645f

Please sign in to comment.