diff --git a/tests/api3.create.test.js b/tests/api3.create.test.js index 054d3e3254b..753d2350d60 100644 --- a/tests/api3.create.test.js +++ b/tests/api3.create.test.js @@ -389,10 +389,10 @@ describe('API3 CREATE', function() { delete doc.identifier; await new Promise((resolve, reject) => { - self.instance.ctx.treatments.create([doc], async (err) => { // let's insert the document in APIv1's way + self.instance.ctx.treatments.create([doc], (err) => { // let's insert the document in APIv1's way should.not.exist(err); doc._id = doc._id.toString(); - self.cache.nextShouldEql(self.col, doc) + self.cache.nextShouldEql(self.col, doc); err ? reject(err) : resolve(doc); }); @@ -416,10 +416,10 @@ describe('API3 CREATE', function() { let updatedBody = await self.get(doc2.identifier); updatedBody.should.containEql(doc2); - self.cache.nextShouldEql(self.col, doc2) + self.cache.nextShouldEql(self.col, doc2); await self.delete(doc2.identifier); - self.cache.nextShouldDeleteLast(self.col) + self.cache.nextShouldDeleteLast(self.col); }); @@ -433,15 +433,17 @@ describe('API3 CREATE', function() { delete doc.identifier; await new Promise((resolve, reject) => { - self.instance.ctx.treatments.create([doc], async (err) => { // let's insert the document in APIv1's way + self.instance.ctx.treatments.create([doc], (err) => { // let's insert the document in APIv1's way should.not.exist(err); doc._id = doc._id.toString(); - self.cache.nextShouldEql(self.col, doc) + self.cache.nextShouldEql(self.col, doc); + err ? reject(err) : resolve(doc); }); }); + const oldBody = await self.get(doc._id); delete doc._id; // APIv1 updates input document, we must get rid of _id for the next round oldBody.should.containEql(doc); @@ -461,13 +463,13 @@ describe('API3 CREATE', function() { updatedBody.identifier.should.not.equal(oldBody.identifier); should.not.exist(updatedBody.isDeduplication); should.not.exist(updatedBody.deduplicatedIdentifier); - self.cache.nextShouldEql(self.col, doc2) + self.cache.nextShouldEql(self.col, doc2); await self.delete(doc2.identifier); - self.cache.nextShouldDeleteLast(self.col) + self.cache.nextShouldDeleteLast(self.col); await self.delete(oldBody.identifier); - self.cache.nextShouldDeleteLast(self.col) + self.cache.nextShouldDeleteLast(self.col); }); @@ -484,7 +486,7 @@ describe('API3 CREATE', function() { let res = await self.instance.delete(`${self.url}/${identifier}`, self.jwt.delete) .expect(200); res.body.status.should.equal(200); - self.cache.nextShouldDeleteLast(self.col) + self.cache.nextShouldDeleteLast(self.col); const date2 = new Date(); res = await self.instance.post(self.url, self.jwt.create) @@ -493,7 +495,7 @@ describe('API3 CREATE', function() { res.body.status.should.equal(403); res.body.message.should.equal('Missing permission api:treatments:update'); - self.cache.shouldBeEmpty() + self.cache.shouldBeEmpty(); const doc2 = Object.assign({}, self.validDoc, { identifier, date: date2.toISOString() }); res = await self.instance.post(`${self.url}`, self.jwt.all) @@ -509,7 +511,7 @@ describe('API3 CREATE', function() { body.identifier.should.equal(identifier); await self.delete(identifier); - self.cache.nextShouldDeleteLast(self.col) + self.cache.nextShouldDeleteLast(self.col); }); @@ -532,7 +534,7 @@ describe('API3 CREATE', function() { self.cache.nextShouldEql(self.col, self.validDoc); await self.delete(validIdentifier); - self.cache.nextShouldDeleteLast(self.col) + self.cache.nextShouldDeleteLast(self.col); }); @@ -571,7 +573,7 @@ describe('API3 CREATE', function() { body.length.should.equal(1); await self.delete(validIdentifier); - self.cache.nextShouldDeleteLast(self.col) + self.cache.nextShouldDeleteLast(self.col); }); }); diff --git a/tests/api3.read.test.js b/tests/api3.read.test.js index c0dbbf1fe32..3d9fa8b2d11 100644 --- a/tests/api3.read.test.js +++ b/tests/api3.read.test.js @@ -74,7 +74,7 @@ describe('API3 READ', function () { res.body.status.should.equal(404); should.not.exist(res.body.result); - self.cache.shouldBeEmpty() + self.cache.shouldBeEmpty(); }); @@ -84,7 +84,7 @@ describe('API3 READ', function () { res.body.status.should.equal(404); should.not.exist(res.body.result); - self.cache.shouldBeEmpty() + self.cache.shouldBeEmpty(); }); @@ -159,7 +159,7 @@ describe('API3 READ', function () { .expect(200); res.body.status.should.equal(200); - self.cache.nextShouldDeleteLast(self.col) + self.cache.nextShouldDeleteLast(self.col); res = await self.instance.get(`${self.url}/${self.validDoc.identifier}`, self.jwt.read) .expect(410); @@ -174,7 +174,7 @@ describe('API3 READ', function () { .expect(200); res.body.status.should.equal(200); - self.cache.nextShouldDeleteLast(self.col) + self.cache.nextShouldDeleteLast(self.col); res = await self.instance.get(`${self.url}/${self.validDoc.identifier}`, self.jwt.read) .expect(404); @@ -192,11 +192,11 @@ describe('API3 READ', function () { delete doc.identifier; await new Promise((resolve, reject) => { - self.instance.ctx.devicestatus.create([doc], async (err) => { // let's insert the document in APIv1's way + self.instance.ctx.devicestatus.create([doc], (err) => { // let's insert the document in APIv1's way should.not.exist(err); doc._id = doc._id.toString(); - self.cache.nextShouldEql(self.col, doc) + self.cache.nextShouldEql(self.col, doc); err ? reject(err) : resolve(doc); }); @@ -215,10 +215,8 @@ describe('API3 READ', function () { .expect(200); res.body.status.should.equal(200); - self.cache.nextShouldDeleteLast(self.col) + self.cache.nextShouldDeleteLast(self.col); }); - - }) ;