Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('says hello worlds!', done => {
request(server)
.get('/')
.expect(200, done);
});
});
it('should only allow admin users to add audits', async () => {
await request(constants.BASE_URL)
.post('/audits')
.set('auth-username', testUtils.nonRootUser.email)
.set('auth-ts', authDetails.authTS)
.set('auth-salt', authDetails.authSalt)
.set('auth-token', authDetails.authToken)
.send(auditData)
.expect(403)
})
})
it('should not allow a non admin user to remove a client', async () => {
await request(constants.BASE_URL)
.del('/clients/000000000000000000000000')
.set('auth-username', testUtils.nonRootUser.email)
.set('auth-ts', authDetails.authTS)
.set('auth-salt', authDetails.authSalt)
.set('auth-token', authDetails.authToken)
.expect(403)
})
})
it('should filter items', async function() {
const res = await request(host).get(`/book?$filter=year(publish_date) eq 2000`);
res.body.value.length.should.greaterThan(0);
res.body.value.should.matchEach((item) => new Date(item.publish_date).getFullYear() === 2000);
});
});
it('should return list of connections', (done) => {
request(app)
.get('/connections')
.expect('Content-Type', /json/)
.expect(200)
.end((err, res) => {
if (err) throw err;
expect(res.body).toEqual(defaultConnections);
done();
});
});
});
.end(() => {
request(listen)
.get('/')
.expect(200, `${goodBody}2`)
.expect(routeHitTwice)
.end(done);
});
}, rateLimitDuration * 2);
function requestToHalfPrice(id) {
return request(host).post(`/book(${id})/50off`);
}
const swm = (token, callback) =>
request(app)
.get('/share/sharedWithMe')
.set('Authorization', 'JWT ' + token)
.set('Accept', 'application/json')
.expect(200)
.end((err, res) =>
err ? callback(err) : callback(null, res.body))
test.serial('Should correctly select just the names and ids', async t => {
const query = {
q: JSON.stringify({ category: 'Getting Started' }),
p: 'slug imgUrl category'
}
const res = await request(server)
.get(`/api/goals?${queryString(query)}`)
.set('Accept', 'application/json')
.expect(200)
.expect('Content-Type', /json/)
const got = res.body
t.is(got.length, 2)
t.is(got[0].name, undefined)
t.is(got[0].slug, 'goal-complete-profile')
})
beforeEach(function(done) {
request(app)
.put('/api/stocks/' + newStock._id)
.send({
name: 'Updated Stock',
info: 'This is the updated stock!!!'
})
.expect(200)
.expect('Content-Type', /json/)
.end(function(err, res) {
if (err) {
return done(err);
}
updatedStock = res.body;
done();
});
});