diff --git a/modules/monitor/back/methods/sales-monitor/specs/salesFilter.spec.js b/modules/monitor/back/methods/sales-monitor/specs/salesFilter.spec.js index 54615b22b..da9d3fbc2 100644 --- a/modules/monitor/back/methods/sales-monitor/specs/salesFilter.spec.js +++ b/modules/monitor/back/methods/sales-monitor/specs/salesFilter.spec.js @@ -103,4 +103,40 @@ describe('SalesMonitor salesFilter()', () => { expect(result.length).toEqual(4); }); + + it('should return the tickets sorted by problems descendant', async() => { + const yesterday = new Date(); + yesterday.setDate(yesterday.getDate() - 1); + yesterday.setHours(0, 0, 0, 0); + const today = new Date(); + today.setHours(23, 59, 59, 59); + + const ctx = {req: {accessToken: {userId: 18}}, args: {}}; + const filter = {order: 'totalProblems DESC'}; + const result = await app.models.SalesMonitor.salesFilter(ctx, filter); + + const firstTicket = result.shift(); + const secondTicket = result.shift(); + + expect(firstTicket.totalProblems).toEqual(3); + expect(secondTicket.totalProblems).toEqual(2); + }); + + it('should return the tickets sorted by problems ascendant', async() => { + const yesterday = new Date(); + yesterday.setDate(yesterday.getDate() - 1); + yesterday.setHours(0, 0, 0, 0); + const today = new Date(); + today.setHours(23, 59, 59, 59); + + const ctx = {req: {accessToken: {userId: 18}}, args: {}}; + const filter = {order: 'totalProblems ASC'}; + const result = await app.models.SalesMonitor.salesFilter(ctx, filter); + + const firstTicket = result.shift(); + const secondTicket = result.shift(); + + expect(firstTicket.totalProblems).toEqual(null); + expect(secondTicket.totalProblems).toEqual(null); + }); });