Skip to content

Construct Integers for mocking Neo4j responses in unit tests? #293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
laurieboyes opened this issue Sep 29, 2017 · 2 comments
Closed

Construct Integers for mocking Neo4j responses in unit tests? #293

laurieboyes opened this issue Sep 29, 2017 · 2 comments

Comments

@laurieboyes
Copy link

As the Integer class exposes no constructor, it's not possible to create Integer instances to use in mocked query responses when writing unit tests for code that deals with Neo4j records.

Is there a recommended alternative solution for mocking Neo4j query responses?

The top of the Integer docs page suggests that there is a way of constructing Integers using the listed 'from*' functions, but I can't find any further reference to these on the page. http://neo4j.com/docs/api/javascript-driver/current/class/src/v1/integer.js~Integer.html

This issue is semi-related to #245, as I believe this and many other use cases would be simplified if the driver offered an option assume all numbers coming back from the database are within the safe 32 bit number range.

Thanks!

@lutovich
Copy link
Contributor

lutovich commented Sep 29, 2017

Hi @laurieboyes,

Thanks for reporting this problem. I think JSDoc is incorrect in this case. Integer does have some from* methods but they are all marked with @access private. Readme suggests using int function https://github.com/neo4j/neo4j-javascript-driver#read-integers, sample code would be:

const neo4j = require('neo4j-driver').v1;
const myInteger = neo4j.int(42);
console.log(myInteger);

and it outputs:

$ node test.js
Integer { low: 42, high: 0 }

Hope this helps. I'll keep this issue open until we fix JSDoc in Integer.

@laurieboyes
Copy link
Author

Ah grand, thanks for the prompt reply!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants