mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
Convert flowDb.spec.js
This commit is contained in:
parent
d7948a845d
commit
3145758411
@ -1,14 +1,15 @@
|
|||||||
import flowDb from './flowDb.js';
|
import flowDb from './flowDb.js';
|
||||||
|
import type { FlowSubGraph } from './types.js';
|
||||||
|
|
||||||
describe('flow db subgraphs', () => {
|
describe('flow db subgraphs', () => {
|
||||||
let subgraphs;
|
let subgraphs: FlowSubGraph[];
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
subgraphs = [
|
subgraphs = [
|
||||||
{ nodes: ['a', 'b', 'c', 'e'] },
|
{ nodes: ['a', 'b', 'c', 'e'] },
|
||||||
{ nodes: ['f', 'g', 'h'] },
|
{ nodes: ['f', 'g', 'h'] },
|
||||||
{ nodes: ['i', 'j'] },
|
{ nodes: ['i', 'j'] },
|
||||||
{ nodes: ['k'] },
|
{ nodes: ['k'] },
|
||||||
];
|
] as FlowSubGraph[];
|
||||||
});
|
});
|
||||||
describe('exist', () => {
|
describe('exist', () => {
|
||||||
it('should return true when the is exists in a subgraph', () => {
|
it('should return true when the is exists in a subgraph', () => {
|
||||||
@ -25,17 +26,17 @@ describe('flow db subgraphs', () => {
|
|||||||
|
|
||||||
describe('makeUniq', () => {
|
describe('makeUniq', () => {
|
||||||
it('should remove ids from sungraph that already exists in another subgraph even if it gets empty', () => {
|
it('should remove ids from sungraph that already exists in another subgraph even if it gets empty', () => {
|
||||||
const subgraph = flowDb.makeUniq({ nodes: ['i', 'j'] }, subgraphs);
|
const subgraph = flowDb.makeUniq({ nodes: ['i', 'j'] } as FlowSubGraph, subgraphs);
|
||||||
|
|
||||||
expect(subgraph.nodes).toEqual([]);
|
expect(subgraph.nodes).toEqual([]);
|
||||||
});
|
});
|
||||||
it('should remove ids from sungraph that already exists in another subgraph', () => {
|
it('should remove ids from sungraph that already exists in another subgraph', () => {
|
||||||
const subgraph = flowDb.makeUniq({ nodes: ['i', 'j', 'o'] }, subgraphs);
|
const subgraph = flowDb.makeUniq({ nodes: ['i', 'j', 'o'] } as FlowSubGraph, subgraphs);
|
||||||
|
|
||||||
expect(subgraph.nodes).toEqual(['o']);
|
expect(subgraph.nodes).toEqual(['o']);
|
||||||
});
|
});
|
||||||
it('should not remove ids from subgraph if they are unique', () => {
|
it('should not remove ids from subgraph if they are unique', () => {
|
||||||
const subgraph = flowDb.makeUniq({ nodes: ['q', 'r', 's'] }, subgraphs);
|
const subgraph = flowDb.makeUniq({ nodes: ['q', 'r', 's'] } as FlowSubGraph, subgraphs);
|
||||||
|
|
||||||
expect(subgraph.nodes).toEqual(['q', 'r', 's']);
|
expect(subgraph.nodes).toEqual(['q', 'r', 's']);
|
||||||
});
|
});
|
Loading…
x
Reference in New Issue
Block a user