test(graph-utils): adjust addEdge tests

This commit is contained in:
moklick
2020-10-29 12:59:24 +01:00
parent ddd3baa5f7
commit e9b4bb4e15

View File

@@ -44,12 +44,19 @@ describe('Graph Utils Testing', () => {
describe('tests addEdge function', () => {
it('adds edge', () => {
const newEdge = { source: '2', target: '3' };
const newEdge = { source: '1', target: '4' };
const nextElements = addEdge(newEdge, elements);
expect(nextElements.length).to.be.equal(elements.length + 1);
});
it('tries to add existing edge', () => {
const newEdge = { source: '2', target: '3' };
const nextElements = addEdge(newEdge, elements);
expect(nextElements.length).to.be.equal(elements.length);
});
it('tries to add invalid edge', () => {
const newEdge = { nosource: '1', notarget: '3' };
@@ -61,18 +68,6 @@ describe('Graph Utils Testing', () => {
expect(e.message).to.be.equal("Can't create edge. An edge needs a source and a target.");
}
});
it('tries to add edge with id that does not exist', () => {
const notExistingId = 'does-not-exist';
const newEdge = { source: notExistingId, target: '3' };
try {
addEdge(newEdge, elements);
} catch (e) {
console.log(e.message);
expect(e.message).to.be.equal(`Can't create edge. Node with id=${notExistingId} does not exist.`);
}
});
});
describe('tests removeElements function', () => {