describe('.deleteUsers', function () { it('should delete a user from the user collection', function () { this.slow(200); return request(app) .delete('/api/users/' +ID) .set('x-access-token', token) .then((res) => { expect(res).to.have.status(200); expect(res.body).to.not.be.null.and.not.be.undefined; }); }); });
it('create challenge - type not found', async () => { const challengeData = _.cloneDeep(testChallengeData) challengeData.typeId = notFoundId const response = await chai.request(app) .post(basePath) .set('Authorization', `Bearer ${config.M2M_UPDATE_ACCESS_TOKEN}`) .send(challengeData) should.equal(response.status, 400) should.equal(response.body.message, `No challenge type found with id: ${notFoundId}.`) })
it('search challenges successfully 2', async () => { const response = await chai.request(app) .get(basePath) .set('Authorization', `Bearer ${config.M2M_FULL_ACCESS_TOKEN}`) .query({ name: 'xxjklsdjfihx' }) should.equal(response.status, 200) should.equal(response.headers['x-page'], '1') should.equal(response.headers['x-per-page'], '20') should.equal(response.headers['x-total'], '0') should.equal(response.headers['x-total-pages'], '0') should.equal(response.body.length, 0) })
it('search audit logs - invalid start date', async () => { const response = await chai.request(app) .get(basePath) .set('Authorization', `Bearer ${config.ADMIN_TOKEN}`) .query({ createdDateStart: 'abc' }) should.equal(response.status, 400) should.equal(response.body.message, '"createdDateStart" must be a number of milliseconds or valid date string') })
it('search audit logs - invalid end date', async () => { const response = await chai.request(app) .get(basePath) .set('Authorization', `Bearer ${config.ADMIN_TOKEN}`) .query({ createdDateEnd: 'abc' }) should.equal(response.status, 400) should.equal(response.body.message, '"createdDateEnd" must be a number of milliseconds or valid date string') })
it('create challenge - invalid projectId', async () => { const challengeData = _.cloneDeep(testChallengeData) challengeData.projectId = -1 const response = await chai.request(app) .post(basePath) .set('Authorization', `Bearer ${config.M2M_UPDATE_ACCESS_TOKEN}`) .send(challengeData) should.equal(response.status, 400) should.equal(response.body.message, '"projectId" must be a positive number') })
it('search challenges - invalid createdDateStart', async () => { const response = await chai.request(app) .get(basePath) .set('Authorization', `Bearer ${config.ADMIN_TOKEN}`) .query({ createdDateStart: 'abc' }) should.equal(response.status, 400) should.equal(response.body.message, '"createdDateStart" must be a number of milliseconds or valid date string') })