cypher-stream
Advanced tools
Comparing version 0.1.7 to 0.1.8
@@ -9,2 +9,5 @@ var oboe = require('oboe'); | ||
function extractData(item) { | ||
if(!item) { | ||
return item; | ||
} | ||
if(item.data) { | ||
@@ -11,0 +14,0 @@ return extractData(item.data); |
{ | ||
"name": "cypher-stream", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"description": "Streams cypher query results in a clean format", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
var should = require('should'); | ||
var cypher = require('../index')('http://localhost:7474'); | ||
function shouldNotError(error) { | ||
should.not.exist(error); | ||
} | ||
describe('Cypher stream', function () { | ||
before(function (done){ | ||
this.timeout(3000); // sometimes travis ci takes too long here | ||
this.timeout(5000); // sometimes travis ci takes too long here | ||
cypher('FOREACH (x IN range(1,10) | CREATE(:Test {test: true}))') | ||
.on('end', done) | ||
.on('error', function (error){ | ||
console.error(error); | ||
}) | ||
.on('error', shouldNotError) | ||
.resume(); | ||
@@ -17,2 +19,3 @@ }); | ||
.on('end', done) | ||
.on('error', shouldNotError) | ||
.resume(); | ||
@@ -26,4 +29,5 @@ }); | ||
results++; | ||
result.n.test.should.be.ok; | ||
result.should.eql({ n: { test: true } }); | ||
}) | ||
.on('error', shouldNotError) | ||
.on('end', function() { | ||
@@ -38,2 +42,3 @@ results.should.eql(10); | ||
var errored = false; | ||
cypher('invalid query') | ||
@@ -56,4 +61,5 @@ .on('error', function (error) { | ||
it('handles non-neo4j errors', function (done) { | ||
var errored = false; | ||
var errored = false; | ||
var expectedError = new Error('Test'); | ||
cypher('match (n:Test) return n limit 1') | ||
@@ -71,3 +77,2 @@ .on('data', function () { | ||
}) | ||
.resume() // need to manually start it since we have no on('data') | ||
; | ||
@@ -79,4 +84,5 @@ }); | ||
.on('data', function (result) { | ||
result.test.should.be.true; | ||
result.should.eql({ test: true }); | ||
}) | ||
.on('error', shouldNotError) | ||
.on('end', done) | ||
@@ -89,4 +95,6 @@ ; | ||
.on('data', function (result) { | ||
result.nodes[0].test.should.be.true; | ||
// 10x { test: true } | ||
result.should.eql({ nodes: [{ test: true }, { test: true }, { test: true }, { test: true }, { test: true }, { test: true }, { test: true }, { test: true }, { test: true }, { test: true } ] }); | ||
}) | ||
.on('error', shouldNotError) | ||
.on('end', done) | ||
@@ -99,4 +107,5 @@ ; | ||
.on('data', function (result) { | ||
result.labels[0].should.equal('Test'); | ||
result.should.eql({ labels: ['Test']}); | ||
}) | ||
.on('error', shouldNotError) | ||
.on('end', done) | ||
@@ -111,2 +120,3 @@ ; | ||
}) | ||
.on('error', shouldNotError) | ||
.on('end', done) | ||
@@ -116,2 +126,12 @@ ; | ||
it('handles null', function (done) { | ||
cypher('return null') | ||
.on('data', function (result) { | ||
result.should.eql({ "null": null }); | ||
}) | ||
.on('error', shouldNotError) | ||
.on('end', done) | ||
; | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20222
192