expressCart/test/specs/orders.js

39 lines
973 B
JavaScript
Raw Normal View History

2019-11-09 12:14:56 +10:00
import{ serial as test }from'ava';
const {
runBefore,
g
} = require('../helper');
test.before(async () => {
await runBefore();
});
test('[Success] Get orders', async t => {
const res = await g.request
.get('/admin/orders')
.set('apiKey', g.users[0].apiKey)
.expect(200);
// Check the returned order length
2020-03-19 17:03:23 +10:00
t.deepEqual(g.jsonData.orders.length, res.body.orders.data.length);
2019-11-09 12:14:56 +10:00
});
test('[Fail] Try get orders with a bogus apiKey', async t => {
const res = await g.request
.get('/admin/orders')
.set('apiKey', '123456789012345678901234')
.expect(400);
t.deepEqual(res.body.message, 'Access denied');
});
test('[Success] Get orders by <Paid> status', async t => {
const res = await g.request
.get('/admin/orders/bystatus/Paid')
.set('apiKey', g.users[0].apiKey)
.expect(200);
// Check the returned order length
t.deepEqual(1, res.body.orders.length);
});