Skip to content

Commit

Permalink
Merge pull request #5077 from mermaid-js/sidv/FlowDB_TS
Browse files Browse the repository at this point in the history
refactor: Convert flowDB to TS
  • Loading branch information
sidharthv96 authored Jan 19, 2024
2 parents 58b6cf0 + e8f6554 commit 6261fce
Show file tree
Hide file tree
Showing 4 changed files with 180 additions and 665 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import flowDb from './flowDb.js';
import type { FlowSubGraph } from './types.js';

describe('flow db subgraphs', () => {
let subgraphs;
let subgraphs: FlowSubGraph[];
beforeEach(() => {
subgraphs = [
{ nodes: ['a', 'b', 'c', 'e'] },
{ nodes: ['f', 'g', 'h'] },
{ nodes: ['i', 'j'] },
{ nodes: ['k'] },
];
] as FlowSubGraph[];
});
describe('exist', () => {
it('should return true when the is exists in a subgraph', () => {
Expand All @@ -25,17 +26,17 @@ describe('flow db subgraphs', () => {

describe('makeUniq', () => {
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([]);
});
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']);
});
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']);
});
Expand Down
Loading

0 comments on commit 6261fce

Please sign in to comment.