Skip to content

Commit

Permalink
activate rest of skipped api tests (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jussi Vatjus-Anttila authored Jan 27, 2019
1 parent 26a41e1 commit caddc2d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 22 deletions.
4 changes: 2 additions & 2 deletions test/tests_api/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ describe('Events', function () {
create('1995-12-18T00:00:00Z', 'ALLOCATED', '1234')
], () => {})
.then(() =>
// duplicate msgid+traceid is rejected
create('1995-12-17T01:00:00Z', 'RELEASED', '123')
// duplicate msgid+traceid is rejected
create('1995-12-17T01:00:00Z', 'RELEASED', '123')
.reflect()
.then((promise) => {
expect(promise.isRejected()).to.be.true;
Expand Down
6 changes: 3 additions & 3 deletions test/tests_api/items.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe('Items', function () {
done();
});

it.skip('should return a list with a SINGLE item on /items?<name> GET', function (done) {
it('should return a list with a SINGLE item on /items?<name> GET', function (done) {
const description =
'Seeeduino Arch from Seeed Studio is an mbed enabled development board which combines some advantages '
+ 'of mbed and Arduino. Arch is based on NXP LPC11U24 with Arduino form factor and Grove connectors. '
Expand Down Expand Up @@ -120,7 +120,7 @@ describe('Items', function () {
});
});

it.skip('should return an image from /items/id/image', function (done) {
it('should return an image from /items/id/image', function (done) {
this.timeout(5000);
superagent.get(`${api}/items/582c7948850f298a5acff981/image`)
.set('authorization', authString)
Expand Down Expand Up @@ -393,7 +393,7 @@ describe('Items', function () {
});
});

it.skip('should not delete item that is loaned somewhere', function (done) {
it('should not delete item that is loaned somewhere', function (done) {
superagent.del(`${api}/items/${itemIdLoaned}`)
.set('authorization', authString)
.end(function (error, res) {
Expand Down
20 changes: 10 additions & 10 deletions test/tests_api/loans.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ describe('Loans', function () {
});
});

it.skip('should accept and remove predefined return dates from a POST', function (done) {
it('should accept and remove predefined return dates from a POST', function (done) {
const body = cloneObject(validLoanBody);
body.items[0].return_date = new Date();

Expand All @@ -186,7 +186,7 @@ describe('Loans', function () {
});
});

it.skip('should add a SINGLE loan on /loans POST', function (done) {
it('should add a SINGLE loan on /loans POST', function (done) {
const body = validLoanBody;
const expectedBody = cloneObject(validLoanBody);
expectedBody.items = undefined; // arrays cannot be compared automatically
Expand Down Expand Up @@ -219,7 +219,7 @@ describe('Loans', function () {
});
});

it.skip('should decrease item availability on POST', function (done) {
it('should decrease item availability on POST', function (done) {
const expectedBody = {available: 4};
superagent.get(`${api}/items/${testItemId}`)
.set('authorization', authString)
Expand All @@ -233,7 +233,7 @@ describe('Loans', function () {
});
});

it.skip('should not accept item without _id field when adding return_date to item on PUT', function (done) {
it('should not accept item without _id field when adding return_date to item on PUT', function (done) {
const body = {items: cloneObject(validLoanBody.items)};
delete body.items[0]._id;
body.items.pop();
Expand All @@ -248,7 +248,7 @@ describe('Loans', function () {
});
});

it.skip('should not accept return PUT with invalid return_date', function (done) {
it('should not accept return PUT with invalid return_date', function (done) {
const body = {items: cloneObject(validLoanBody.items)};
body.items[0].return_date = 'invalid date';

Expand All @@ -262,7 +262,7 @@ describe('Loans', function () {
});
});

it.skip('should accept return PUT with valid return_date', function (done) {
it('should accept return PUT with valid return_date', function (done) {
const testDate = new Date();
const body = {items: cloneObject(validLoanBody.items)};
body.items[1].return_date = testDate;
Expand All @@ -280,7 +280,7 @@ describe('Loans', function () {
});
});

it.skip('should update a SINGLE item on /loans/<id> PUT', function (done) {
it('should update a SINGLE item on /loans/<id> PUT', function (done) {
const testDate = new Date();
const body = {loan_date: testDate};

Expand All @@ -307,7 +307,7 @@ describe('Loans', function () {
});
});

it.skip('should increase item availability on PUT', function (done) { // Should be after the relevant put
it('should increase item availability on PUT', function (done) { // Should be after the relevant put
const expectedBody = {available: 5};

superagent.get(`${api}/items/${testItemId}`)
Expand All @@ -321,7 +321,7 @@ describe('Loans', function () {
});

// Should be the second last test for loans
it.skip('should delete a SINGLE loan on /loans/<id> DELETE', function (done) {
it('should delete a SINGLE loan on /loans/<id> DELETE', function (done) {
const loanRoute = `${api}/loans/${testLoanId}`;
superagent.del(loanRoute)
.set('authorization', authString)
Expand All @@ -342,7 +342,7 @@ describe('Loans', function () {
});

// Make sure items availability changed on delete
it.skip('should increase availablity on deleted item for all unreturned items', function (done) {
it('should increase availablity on deleted item for all unreturned items', function (done) {
const expectedBody = {available: 7};

superagent.get(`${api}/items/${testItemId}`)
Expand Down
9 changes: 2 additions & 7 deletions test/tests_api/results.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const api = 'http://localhost:3000/api/v0';
const validResultBody = require('./mocking/mockResult.json');

const existingResultId = '5858375fbee7d73c703c5e13';
const existingResultBody = require('./expectedValues/expectedResult.json');

const relativeFiledbPath = config.get('filedb');
const absoluteFiledbPath = path.resolve(__dirname, '..', '..', relativeFiledbPath);
Expand Down Expand Up @@ -53,17 +52,13 @@ describe('Results', function () {
});
});

it.skip('should return a single result on results/<id> GET', function (done) {
const expectedBody = existingResultBody;

it('should return a single result on results/<id> GET', function (done) {
superagent.get(`${api}/results/${existingResultId}`)
.set('authorization', authString)
.type('json')
.end(function (error, res) {
expect(error).to.not.exist;

expect(res.body).to.deep.equal(expectedBody);

expect(res.body._id).to.equal(existingResultId);
done();
});
});
Expand Down

0 comments on commit caddc2d

Please sign in to comment.