eh-api-client
Advanced tools
Comparing version 0.12.0 to 0.13.0
@@ -240,2 +240,3 @@ var | ||
var c = new Client(this.apiURL); | ||
c._factory = this; | ||
return c.exists.apply(c, arguments); | ||
@@ -242,0 +243,0 @@ }; |
{ | ||
"name": "eh-api-client", | ||
"version": "0.12.0", | ||
"version": "0.13.0", | ||
"description": "Node.js rest client", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
var | ||
Factory = require("../index"), | ||
should = require("should"), | ||
sinon = require("sinon"); | ||
sinon = require("sinon"), | ||
http = require("http"); | ||
var SERVER_PORT = 8591; | ||
var url = "http://localhost:" + SERVER_PORT; | ||
function createServer(cb) { | ||
var server = http.createServer(); | ||
server.listen(SERVER_PORT, function() { | ||
cb(server); | ||
}); | ||
} | ||
describe("#exists", function() { | ||
var factory = new Factory("http://localhost"); | ||
var factory = new Factory(url); | ||
var client = factory.getClient(1, "test"); | ||
describe("tests real server", function() { | ||
var s; | ||
var returnStatus = 200; | ||
var lastReq; | ||
before(function(done) { | ||
createServer(function(_s) { | ||
s = _s; | ||
s.on("request", function(req, res) { | ||
lastReq = req; | ||
res.statusCode = returnStatus; | ||
res.end("Done"); | ||
}); | ||
done(); | ||
}); | ||
}); | ||
after(function(done) { | ||
s.close(done); | ||
}); | ||
it("should exists", function(done) { | ||
factory.exists("/test", function(err, exists) { | ||
should.not.exists(err); | ||
should.ok(exists); | ||
done(); | ||
}); | ||
}); | ||
it("should not exists", function(done) { | ||
returnStatus = 404; | ||
factory.exists("/test", function(err, exists) { | ||
should.not.exists(err); | ||
exists.should.equal(false); | ||
done(); | ||
}); | ||
}); | ||
it("should be error", function(done) { | ||
returnStatus = 500; | ||
factory.exists("/test", function(err) { | ||
should.exist(err); | ||
err.httpStatus.should.equal(500); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
describe("resource exists", function() { | ||
@@ -10,0 +68,0 @@ before(function() { |
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
17147
338
620
3