it("should return an empty list of Queues",function(done){ test .get('/queues') .end(function(err,res){ res.status.should.equal(200); res.body.should.have.lengthOf(0); broker.qManager.should.have.lengthOf(1); // We only delete Queue from array, deleted Queues still effect the length... should.not.exist(broker.qManager[0]); done(); }); });
describe('/items/:id', function(){ it('should return status 200 and the item with passed id', function(done){ supertest(app) .get('/items/5421c0eb3f37951d5c000019') .expect(200) .end(function(err, res){ assert.equal(res.status, 200, "HTTP response OK"); assert.isObject(res.body.data, "Should return an object"); done(); }) }); });
this.When(/^I shedule an export/, function (callback) { request(app) .post('/v2/exports') .set('Content-Type', 'application/json') .use(this.setAuthorizationHeader(this.uid)) .expect('Content-Type', /json/) .expect((res) => { expect(res.status).to.equals(202) }) .end(callback) })
it("should *FAIL* rename Queue #3 -- unmatched queue_id",function(done){ test .put('/queues/3') .send('name=BeerQueue') .end(function(err,res){ res.status.should.equal(410); res.body.status.should.equal('error'); broker.qManager.should.have.lengthOf(1); broker.qManager[0].name.should.equal('BeerQueue'); done(); }); });
describe('test/app.test.js', function() { it('should / status 200', function(done) { request(app) .get('/') .end(function(err, res) { res.status.should.equal(200) res.text.should.containEql(config.description) done() }) }) })
it('should return status 200 and all the items belonging to passed userId and within 50 miles range of passed coordinates', function(done){ supertest(app) .get('/items?userId=53fd1d5f646d8f233e000015&lattitude=36.1650672625387415&longitude=-115.1394261163364092') .expect(200) .end(function(err, res){ assert.equal(res.status, 200, "HTTP response OK"); assert.notStrictEqual(res.body.data.length, 100, "Should not return all the data"); assert.notStrictEqual(res.body.data.length, 0, "Should return one or more records"); done(); }) });
it("should return an list with one Queue named 'PeopleQueue' with ID == 0",function(done){ test .get('/queues') .end(function(err,res){ res.status.should.equal(200); res.body.should.have.lengthOf(1); res.body[0].id.should.equal(0); res.body[0].name.should.equal('PeopleQueue'); broker.qManager.should.have.lengthOf(1); done(); }); });
it('should return status 400 - invalid parameter if invalid query parameter is passed', function(done){ supertest(app) .get('/items?sortingOrder=A') .expect(400) .end(function(err, res){ assert.equal(res.status, 400, "HTTP Error - Invalid parameter"); done(); }) });
it('should return status 200 and all the items when no query parameter is passed', function(done){ supertest(app) .get('/items') .expect(200) .end(function(err, res){ assert.equal(res.status, 200, "HTTP response OK"); assert.equal(res.body.data.length, 100, "Should return all the data") done(); }) });
it("should delete the queue of ID == 0'",function(done){ test .delete('/queues/0') .end(function(err,res){ res.status.should.equal(200); res.body.status.should.equal('ok'); broker.qManager.should.have.lengthOf(1); // We only delete Queue from array, deleted Queues still effect the length... should.not.exist(broker.qManager[0]); done(); }); });
it("should NOT create a new Queue",function(done){ test .post('/queues') .send('nameWrongField=NotCreatedQueue') .end(function(err,res){ res.status.should.equal(400); res.body.status.should.equal('error'); broker.qManager.should.have.lengthOf(1); broker.qManager[0].name.should.equal('PeopleQueue'); // Optionally, make sure nothing changes from above test. done(); }); });
it("should *FAIL* rename Queue #3 -- queue_id is wrongfully string",function(done){ test .put('/queues/john') .send('name=BeerQueue') .end(function(err,res){ res.status.should.equal(400); res.body.status.should.equal('error'); broker.qManager.should.have.lengthOf(1); broker.qManager[0].name.should.equal('BeerQueue'); done(); }); });
it('should return status 200 and all the items belonging to particular userId when only userId is passed', function(done){ supertest(app) .get('/items?userId=53fd1d5f646d8f233e000015') .expect(200) .end(function(err, res){ assert.equal(res.status, 200, "HTTP response OK"); assert.notStrictEqual(res.body.data.length, 100, "Should not return all the data"); assert.notStrictEqual(res.body.data.length, 0, "Should return one or more records"); done(); }) });