Made async tests sync to allow for propert execution of before()
diff --git a/tests/lib/client.test.js b/tests/lib/client.test.js
index 1115f95..54e6a39 100644
--- a/tests/lib/client.test.js
+++ b/tests/lib/client.test.js
@@ -52,30 +52,35 @@
- it('should not fail when a callback function is not passed', function() {
+ it('should not fail when a callback function is not passed', function(done) {
// note: this test will NOT fail gracefully inside the Mocha event chain
client.GET(_collection)
+ done()
})
- it('should return a 200 ok', function() {
- console.log(response, client)
+ it('should return a 200 ok', function(done) {
response.statusCode.should.equal(200)
+ done()
})
- it('response.entities should be an array', function() {
+ it('response.entities should be an array', function(done) {
response.entities.should.be.an.Array
+ done()
})
- it('response.first should exist and have a valid uuid', function() {
+ it('response.first should exist and have a valid uuid', function(done) {
response.first.should.be.an.Object.with.property('uuid').with.a.lengthOf(36)
+ done()
})
- it('response.entity should exist and have a valid uuid', function() {
+ it('response.entity should exist and have a valid uuid', function(done) {
response.entity.should.be.an.Object.with.property('uuid').with.a.lengthOf(36)
+ done()
})
- it('response.last should exist and have a valid uuid', function() {
+ it('response.last should exist and have a valid uuid', function(done) {
response.last.should.be.an.Object.with.property('uuid').with.a.lengthOf(36)
+ done()
})
})
@@ -96,25 +101,30 @@
})
})
- it('should not fail when a callback function is not passed', function() {
+ it('should not fail when a callback function is not passed', function(done) {
// note: this test will NOT fail gracefully inside the Mocha event chain
client.POST(_collection, {})
+ done()
})
- it('should return a 200 ok', function() {
+ it('should return a 200 ok', function(done) {
response.statusCode.should.equal(200)
+ done()
})
- it('response.entities should be an array', function() {
+ it('response.entities should be an array', function(done) {
response.entities.should.be.an.Array.with.a.lengthOf(1)
+ done()
})
- it('response.entity should exist and have a valid uuid', function() {
+ it('response.entity should exist and have a valid uuid', function(done) {
response.entity.should.be.an.Object.with.property('uuid').with.a.lengthOf(36)
+ done()
})
- it('response.entity.author should equal "Sir Arthur Conan Doyle"', function() {
+ it('response.entity.author should equal "Sir Arthur Conan Doyle"', function(done) {
response.entity.should.have.property('author').equal('Sir Arthur Conan Doyle')
+ done()
})
})
@@ -134,25 +144,30 @@
})
})
- it('should not fail when a callback function is not passed', function() {
+ it('should not fail when a callback function is not passed', function(done) {
// note: this test will NOT fail gracefully inside the Mocha event chain
client.PUT(_collection, _uuid)
+ done()
})
- it('should return a 200 ok', function() {
+ it('should return a 200 ok', function(done) {
response.statusCode.should.equal(200)
+ done()
})
- it('response.entities should be an array', function() {
+ it('response.entities should be an array', function(done) {
response.entities.should.be.an.Array.with.a.lengthOf(1)
+ done()
})
- it('response.entity should exist and its uuid should the uuid from the previous POST requets', function() {
+ it('response.entity should exist and its uuid should the uuid from the previous POST requets', function(done) {
response.entity.should.be.an.Object.with.property('uuid').equal(_uuid)
+ done()
})
- it('response.entity.narrator should equal "Peter Doyle"', function() {
+ it('response.entity.narrator should equal "Peter Doyle"', function(done) {
response.entity.should.have.property('narrator').equal('Peter Doyle')
+ done()
})
})
@@ -172,19 +187,22 @@
})
})
- it('should not fail when a callback function is not passed', function() {
+ it('should not fail when a callback function is not passed', function(done) {
// note: this test will NOT fail gracefully inside the Mocha event chain
client.DELETE(_collection, _uuid)
+ done()
})
- it('should return a 200 ok', function() {
+ it('should return a 200 ok', function(done) {
// This should check for 404, but because of a Usergrid bug, it returns 401 instead of 404.
// see https://issues.apache.org/jira/browse/USERGRID-1128
response.statusCode.should.not.equal(200)
+ done()
})
- it('response.error.name should equal "service_resource_not_found"', function() {
+ it('response.error.name should equal "service_resource_not_found"', function(done) {
response.error.name.should.equal('service_resource_not_found')
+ done()
})
})
@@ -204,21 +222,25 @@
})
})
- it('should return a 200 ok', function() {
+ it('should return a 200 ok', function(done) {
response.statusCode.should.equal(200)
+ done()
})
- it('should have a valid token', function() {
+ it('should have a valid token', function(done) {
token.should.be.a.String
token.length.should.be.greaterThan(10)
+ done()
})
- it('client.appAuth.token should be set to the token returned from Usergrid', function() {
+ it('client.appAuth.token should be set to the token returned from Usergrid', function(done) {
client.appAuth.should.have.property('token').equal(token)
+ done()
})
- it('client.appAuth.expiry should be set to a future date', function() {
+ it('client.appAuth.expiry should be set to a future date', function(done) {
client.appAuth.should.have.property('expiry').greaterThan(Date.now())
+ done()
})
})