How to use the neo4j-driver.mockSessionRun function in neo4j-driver

To help you get started, we’ve selected a few neo4j-driver examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github neo4j-contrib / neovis.js / __tests__ / neovis.tests.js View on Github external
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);
		});
	});
github neo4j-contrib / neovis.js / __tests__ / neovis.tests.js View on Github external
it('should call run with query', () => {
			neovis.render();
			expect(Neo4jMock.mockSessionRun).toHaveBeenCalledWith(initial_cypher, {limit: 30});
		});
github neo4j-contrib / neovis.js / __tests__ / testUtils.js View on Github external
export function mockNormalRunSubscribe(records = []) {
	Neo4jMock.mockSessionRun.mockImplementation(() => {
		const observablePromise = Promise.resolve({records});
		observablePromise.subscribe = ({onNext, onCompleted}) => {
			records.forEach(onNext);
			onCompleted();
		};
		return observablePromise;
	});
}