2126 - Search by client name
gitea/salix/2126-ticket_weekly_search_by_name This commit looks good
Details
gitea/salix/2126-ticket_weekly_search_by_name This commit looks good
Details
This commit is contained in:
parent
224241a954
commit
d0c2f88a77
|
@ -38,7 +38,8 @@ module.exports = Self => {
|
|||
case 'search':
|
||||
return {or: [
|
||||
{'t.id': value},
|
||||
{'c.id': value}
|
||||
{'c.id': value},
|
||||
{'c.name': {like: `%${value}%`}}
|
||||
]};
|
||||
}
|
||||
});
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('ticket-weekly filter()', () => {
|
||||
const authUserId = 9;
|
||||
it('should return the tickets matching the filter', async() => {
|
||||
const ctx = {req: {accessToken: {userId: authUserId}}, args: {}};
|
||||
const filter = {order: 'id DESC'};
|
||||
const result = await app.models.TicketWeekly.filter(ctx, filter);
|
||||
const firstRow = result[0];
|
||||
|
||||
expect(firstRow.ticketFk).toEqual(1);
|
||||
});
|
||||
|
||||
it('should return the ticket with id one', async() => {
|
||||
const ctx = {req: {accessToken: {userId: authUserId}}, args: {search: 2}};
|
||||
const filter = {};
|
||||
const result = await app.models.TicketWeekly.filter(ctx, filter);
|
||||
const firstRow = result[0];
|
||||
|
||||
expect(firstRow.ticketFk).toEqual(2);
|
||||
});
|
||||
|
||||
it('should return the ticket matching the client name', async() => {
|
||||
const ctx = {req: {accessToken: {userId: authUserId}}, args: {search: 'bruce'}};
|
||||
const filter = {};
|
||||
const result = await app.models.TicketWeekly.filter(ctx, filter);
|
||||
const firstRow = result[0];
|
||||
|
||||
expect(firstRow.clientName).toEqual('Bruce Wayne');
|
||||
});
|
||||
|
||||
it('should return the ticket matching the client id', async() => {
|
||||
const ctx = {req: {accessToken: {userId: authUserId}}, args: {search: 101}};
|
||||
const filter = {};
|
||||
const result = await app.models.TicketWeekly.filter(ctx, filter);
|
||||
const firstRow = result[0];
|
||||
|
||||
expect(firstRow.clientFk).toEqual(101);
|
||||
expect(firstRow.clientName).toEqual('Bruce Wayne');
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue