Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should call sizeCypher and save return value to data set value', async () => {
const node = testUtils.makeNode([label1]);
testUtils.mockFullRunSubscribe({
[initial_cypher]: {
default: [testUtils.makeRecord([node])]
},
[sizeCypher]: {
[node.identity.toInt()]: [testUtils.makeRecord([Neo4j.int(1)])]
}
});
neovis.render();
await testUtils.neovisRenderDonePromise(neovis);
expect(Neo4jMock.mockSessionRun).toHaveBeenCalledTimes(1 + 1); // once for initial cypher and once for the sizeCypher
expect(neovis._data.nodes.get(1)).toHaveProperty('value', 1);
});
});
it('should call run with query', () => {
neovis.render();
expect(Neo4jMock.mockSessionRun).toHaveBeenCalledWith(initial_cypher, {limit: 30});
});
export function mockNormalRunSubscribe(records = []) {
Neo4jMock.mockSessionRun.mockImplementation(() => {
const observablePromise = Promise.resolve({records});
observablePromise.subscribe = ({onNext, onCompleted}) => {
records.forEach(onNext);
onCompleted();
};
return observablePromise;
});
}