41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
const app = require('vn-loopback/server/server');
|
|
|
|
describe('client consumption() filter', () => {
|
|
it('should return a list of buyed items by ticket', async() => {
|
|
const ctx = {req: {accessToken: {userId: 9}}, args: {}};
|
|
const filter = {
|
|
where: {
|
|
clientFk: 101
|
|
},
|
|
order: 'itemTypeFk, itemName, itemSize'
|
|
};
|
|
const result = await app.models.Client.consumption(ctx, filter);
|
|
|
|
expect(result.length).toEqual(10);
|
|
});
|
|
|
|
it('should return a list of tickets grouped by item', async() => {
|
|
const ctx = {req: {accessToken: {userId: 9}},
|
|
args: {
|
|
grouped: true
|
|
}
|
|
};
|
|
const filter = {
|
|
where: {
|
|
clientFk: 101
|
|
},
|
|
order: 'itemTypeFk, itemName, itemSize'
|
|
};
|
|
const result = await app.models.Client.consumption(ctx, filter);
|
|
|
|
const firstRow = result[0];
|
|
const secondRow = result[1];
|
|
const thirdRow = result[2];
|
|
|
|
expect(result.length).toEqual(3);
|
|
expect(firstRow.quantity).toEqual(10);
|
|
expect(secondRow.quantity).toEqual(15);
|
|
expect(thirdRow.quantity).toEqual(20);
|
|
});
|
|
});
|