forked from finos/architecture-as-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode-id-exists.spec.ts
More file actions
50 lines (44 loc) · 1.44 KB
/
node-id-exists.spec.ts
File metadata and controls
50 lines (44 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { nodeIdExists } from './node-id-exists';
describe('nodeIdExists', () => {
it('should return an empty array when there is no input', () => {
const input = null;
const context = {
document: {
data: {}
}
};
const result = nodeIdExists(input, null, context);
expect(result).toEqual([]);
});
it('should return an empty array when the ID exists', () => {
const input = 'node1';
const context = {
document: {
data: {
nodes: [
{'unique-id': 'node1'}
]
}
}
};
const result = nodeIdExists(input, null, context);
expect(result).toEqual([]);
});
it('should return a message when the ID does not exist', () => {
const input = 'node2';
const context = {
document: {
data: {
nodes: [
{'unique-id': 'node1'}
]
}
},
path: ['/relationships/0/connects/destination']
};
const result = nodeIdExists(input, null, context);
expect(result.length).toBe(1);
expect(result[0].message).toBe(`'${input}' does not refer to the unique-id of an existing node.`);
expect(result[0].path).toEqual(['/relationships/0/connects/destination']);
});
});