Skip to content

Commit

Permalink
test: refine test
Browse files Browse the repository at this point in the history
  • Loading branch information
Yanyan-Wang committed Jun 4, 2021
1 parent 0ceb639 commit 21f21bb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/pc/tests/unit/layout/circular-web-worker-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,19 @@ describe('circular layout(web worker)', () => {
graph.data(data);
graph.render();

let timeout = false;
graph.on('afterlayout', () => {
if (timeout) return;
const pos = (200 * Math.sqrt(2)) / 2;
expect(mathEqual(data.nodes[0].x, 250 + pos)).toEqual(true);
expect(mathEqual(data.nodes[0].y, 250 + pos)).toEqual(true);
graph.destroy();
done();
});
setTimeout(() => {
timeout = true;
graph.destroy();
done();
}, 1000)
});
});
7 changes: 7 additions & 0 deletions packages/pc/tests/unit/layout/force-web-worker-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ describe('force layout(web worker)', function () {
height: 500,
defaultNode: { size: 10 },
});
let timeout = false;
graph.on('afterlayout', () => {
if (timeout) return;
expect(node.x).not.toEqual(undefined);
expect(node.y).not.toEqual(undefined);
expect(count >= 1).toEqual(true);
Expand All @@ -45,5 +47,10 @@ describe('force layout(web worker)', function () {
});
graph.data(data);
graph.render();
setTimeout(() => {
timeout = true;
graph.destroy();
done();
}, 4000)
});
});

0 comments on commit 21f21bb

Please sign in to comment.