feat(db): static dates
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Alex Moreno 2022-03-30 12:45:01 +02:00
parent 419ec4ac18
commit eec1c1ff86
99 changed files with 10297 additions and 10977 deletions

View File

@ -2,7 +2,7 @@ const app = require('vn-loopback/server/server');
describe('campaign latest()', () => { describe('campaign latest()', () => {
it('should return the campaigns from the last year', async() => { it('should return the campaigns from the last year', async() => {
const now = new Date(); const now = new Date('2022-01-19');
const result = await app.models.Campaign.latest(); const result = await app.models.Campaign.latest();
const randomIndex = Math.floor(Math.random() * result.length); const randomIndex = Math.floor(Math.random() * result.length);
const campaignDated = result[randomIndex].dated; const campaignDated = result[randomIndex].dated;
@ -12,7 +12,7 @@ describe('campaign latest()', () => {
}); });
it('should return the campaigns from the current year', async() => { it('should return the campaigns from the current year', async() => {
const now = new Date(); const now = new Date('2022-01-19');
const currentYear = now.getFullYear(); const currentYear = now.getFullYear();
const result = await app.models.Campaign.latest({ const result = await app.models.Campaign.latest({
where: {dated: {like: `%${currentYear}%`}} where: {dated: {like: `%${currentYear}%`}}

View File

@ -4,7 +4,7 @@ describe('campaign upcoming()', () => {
it('should return the upcoming campaign but from the last year', async() => { it('should return the upcoming campaign but from the last year', async() => {
const response = await app.models.Campaign.upcoming(); const response = await app.models.Campaign.upcoming();
const campaignDated = response.dated; const campaignDated = response.dated;
const now = new Date(); const now = new Date('2022-01-19');
expect(campaignDated).toEqual(jasmine.any(Date)); expect(campaignDated).toEqual(jasmine.any(Date));
expect(campaignDated).toBeLessThanOrEqual(now); expect(campaignDated).toBeLessThanOrEqual(now);

View File

@ -1,7 +1,7 @@
const models = require('vn-loopback/server/server').models; const models = require('vn-loopback/server/server').models;
describe('Chat sendCheckingPresence()', () => { describe('Chat sendCheckingPresence()', () => {
const today = new Date(); const today = new Date('2022-01-19');
today.setHours(6, 0); today.setHours(6, 0);
const ctx = {req: {accessToken: {userId: 1}}}; const ctx = {req: {accessToken: {userId: 1}}};
const chatModel = models.Chat; const chatModel = models.Chat;

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -96,5 +96,12 @@ mysqldump \
--databases \ --databases \
${SCHEMAS[@]} \ ${SCHEMAS[@]} \
${IGNORETABLES[@]} \ ${IGNORETABLES[@]} \
| sed 's/\bCURDATE\b/vn.VN_CURDATE/ig'\
| sed 's/\bCURTIME\b/vn.VN_CURTIME/g' \
| sed 's/\bNOW\b/vn.VN_NOW/g' \
| sed 's/\bCURRENT_DATE\b/vn.VN_CURDATE/g' \
| sed 's/\bCURRENT_TIME\b/vn.VN_CURTIME/g' \
| sed 's/\bLOCALTIME\b/vn.VN_NOW/g' \
| sed 's/\bLOCALTIMESTAMP\b/vn.VN_NOW/g' \
| sed 's/ AUTO_INCREMENT=[0-9]* //g' \ | sed 's/ AUTO_INCREMENT=[0-9]* //g' \
> dump/structure.sql > dump/structure.sql

View File

@ -2,7 +2,7 @@ const app = require('vn-loopback/server/server');
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
describe('buyUltimate()', () => { describe('buyUltimate()', () => {
const today = new Date(); const today = new Date('2022-01-19');
it(`should create buyUltimate temporal table and update it's values`, async() => { it(`should create buyUltimate temporal table and update it's values`, async() => {
let stmts = []; let stmts = [];
let stmt; let stmt;

View File

@ -5,7 +5,7 @@ describe('buyUltimateFromInterval()', () => {
let today; let today;
let future; let future;
beforeAll(() => { beforeAll(() => {
let now = new Date(); let now = new Date('2022-01-19');
now.setHours(0, 0, 0, 0); now.setHours(0, 0, 0, 0);
today = now; today = now;

View File

@ -2,7 +2,7 @@ const app = require('vn-loopback/server/server');
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
describe('ticket ticketCalculateClon()', () => { describe('ticket ticketCalculateClon()', () => {
const today = new Date(); const today = new Date('2022-01-19');
it('should add the ticket to the order containing the original ticket', async() => { it('should add the ticket to the order containing the original ticket', async() => {
let stmts = []; let stmts = [];
let stmt; let stmt;

View File

@ -2,7 +2,7 @@ const app = require('vn-loopback/server/server');
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
describe('ticket ticketCreateWithUser()', () => { describe('ticket ticketCreateWithUser()', () => {
const today = new Date(); const today = new Date('2022-01-19');
it('should confirm the procedure creates the expected ticket', async() => { it('should confirm the procedure creates the expected ticket', async() => {
let stmts = []; let stmts = [];
let stmt; let stmt;

View File

@ -3,9 +3,9 @@ const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
describe('timeBusiness_calculateByUser()', () => { describe('timeBusiness_calculateByUser()', () => {
it('should return the expected hours for today', async() => { it('should return the expected hours for today', async() => {
let start = new Date(); let start = new Date('2022-01-19');
start.setHours(0, 0, 0, 0); start.setHours(0, 0, 0, 0);
let end = new Date(); let end = new Date('2022-01-19');
end.setHours(0, 0, 0, 0); end.setHours(0, 0, 0, 0);
let stmts = []; let stmts = [];

View File

@ -3,11 +3,11 @@ const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
describe('timeControl_calculateByUser()', () => { describe('timeControl_calculateByUser()', () => {
it(`should return today's worked hours`, async() => { it(`should return today's worked hours`, async() => {
let start = new Date(); let start = new Date('2022-01-19');
start.setHours(0, 0, 0, 0); start.setHours(0, 0, 0, 0);
start.setDate(start.getDate() - 1); start.setDate(start.getDate() - 1);
let end = new Date(); let end = new Date('2022-01-19');
end.setHours(0, 0, 0, 0); end.setHours(0, 0, 0, 0);
end.setDate(end.getDate() + 1); end.setDate(end.getDate() + 1);
@ -48,14 +48,14 @@ describe('timeControl_calculateByUser()', () => {
}); });
it(`should return the worked hours between last sunday and monday`, async() => { it(`should return the worked hours between last sunday and monday`, async() => {
let lastSunday = new Date(); let lastSunday = new Date('2022-01-19');
let daysSinceSunday = lastSunday.getDay(); let daysSinceSunday = lastSunday.getDay();
if (daysSinceSunday === 0) // this means today is sunday but you need the previous sunday :) if (daysSinceSunday === 0) // this means today is sunday but you need the previous sunday :)
daysSinceSunday = 7; daysSinceSunday = 7;
lastSunday.setHours(23, 0, 0, 0); lastSunday.setHours(23, 0, 0, 0);
lastSunday.setDate(lastSunday.getDate() - daysSinceSunday); lastSunday.setDate(lastSunday.getDate() - daysSinceSunday);
let monday = new Date(); let monday = new Date('2022-01-19');
let daysSinceMonday = daysSinceSunday - 1; // aiming for monday (today could be monday) let daysSinceMonday = daysSinceSunday - 1; // aiming for monday (today could be monday)
monday.setHours(7, 0, 0, 0); monday.setHours(7, 0, 0, 0);
monday.setDate(monday.getDate() - daysSinceMonday); monday.setDate(monday.getDate() - daysSinceMonday);

View File

@ -4,7 +4,7 @@ import getBrowser from '../../helpers/puppeteer';
describe('Client credit insurance path', () => { describe('Client credit insurance path', () => {
let browser; let browser;
let page; let page;
let previousMonth = new Date(); let previousMonth = new Date('2022-01-19');
previousMonth.setMonth(previousMonth.getMonth() - 1); previousMonth.setMonth(previousMonth.getMonth() - 1);
beforeAll(async() => { beforeAll(async() => {

View File

@ -120,7 +120,7 @@ describe('Worker calendar path', () => {
}); });
it('should use the year selector to go to the previous year', async() => { it('should use the year selector to go to the previous year', async() => {
const date = new Date(); const date = new Date('2022-01-19');
const lastYear = (date.getFullYear() - 1).toString(); const lastYear = (date.getFullYear() - 1).toString();
await page.autocompleteSearch(selectors.workerCalendar.year, lastYear); await page.autocompleteSearch(selectors.workerCalendar.year, lastYear);

View File

@ -22,7 +22,7 @@ describe('Item fixed prices path', () => {
}); });
it('should fill the fixed price data', async() => { it('should fill the fixed price data', async() => {
const now = new Date(); const now = new Date('2022-01-19');
await page.autocompleteSearch(selectors.itemFixedPrice.fourthWarehouse, 'Warehouse one'); await page.autocompleteSearch(selectors.itemFixedPrice.fourthWarehouse, 'Warehouse one');
await page.write(selectors.itemFixedPrice.fourthPPU, '1'); await page.write(selectors.itemFixedPrice.fourthPPU, '1');
await page.write(selectors.itemFixedPrice.fourthPPP, '1'); await page.write(selectors.itemFixedPrice.fourthPPP, '1');

View File

@ -93,7 +93,7 @@ describe('Ticket Edit basic data path', () => {
it(`should split ticket without negatives`, async() => { it(`should split ticket without negatives`, async() => {
const newAgency = 'Silla247'; const newAgency = 'Silla247';
const newDate = new Date(); const newDate = new Date('2022-01-19');
newDate.setDate(newDate.getDate() - 1); newDate.setDate(newDate.getDate() - 1);
await page.accessToSearchResult('14'); await page.accessToSearchResult('14');
@ -128,7 +128,7 @@ describe('Ticket Edit basic data path', () => {
}); });
it(`should old ticket have old date and agency`, async() => { it(`should old ticket have old date and agency`, async() => {
const oldDate = new Date(); const oldDate = new Date('2022-01-19');
const oldAgency = 'Super-Man delivery'; const oldAgency = 'Super-Man delivery';
await page.accessToSearchResult('14'); await page.accessToSearchResult('14');

View File

@ -4,7 +4,7 @@ import getBrowser from '../../helpers/puppeteer';
describe('Ticket create path', () => { describe('Ticket create path', () => {
let browser; let browser;
let page; let page;
let nextMonth = new Date(); let nextMonth = new Date('2022-01-19');
nextMonth.setMonth(nextMonth.getMonth() + 1); nextMonth.setMonth(nextMonth.getMonth() + 1);
let stowawayTicketId; let stowawayTicketId;

View File

@ -18,7 +18,7 @@ describe('Route basic Data path', () => {
}); });
it('should edit the route basic data', async() => { it('should edit the route basic data', async() => {
const nextMonth = new Date(); const nextMonth = new Date('2022-01-19');
nextMonth.setMonth(nextMonth.getMonth() + 1); nextMonth.setMonth(nextMonth.getMonth() + 1);
await page.autocompleteSearch(selectors.routeBasicData.worker, 'adminBossNick'); await page.autocompleteSearch(selectors.routeBasicData.worker, 'adminBossNick');

View File

@ -18,7 +18,7 @@ describe('InvoiceIn basic data path', () => {
}); });
it(`should edit the invoiceIn basic data`, async() => { it(`should edit the invoiceIn basic data`, async() => {
const now = new Date(); const now = new Date('2022-01-19');
await page.pickDate(selectors.invoiceInBasicData.issued, now); await page.pickDate(selectors.invoiceInBasicData.issued, now);
await page.pickDate(selectors.invoiceInBasicData.operated, now); await page.pickDate(selectors.invoiceInBasicData.operated, now);
await page.autocompleteSearch(selectors.invoiceInBasicData.supplier, 'Verdnatura'); await page.autocompleteSearch(selectors.invoiceInBasicData.supplier, 'Verdnatura');

View File

@ -100,7 +100,7 @@ describe('InvoiceOut descriptor path', () => {
}); });
it(`should check the invoiceOut booked in the summary data`, async() => { it(`should check the invoiceOut booked in the summary data`, async() => {
let today = new Date(); let today = new Date('2022-01-19');
let day = today.getDate(); let day = today.getDate();
if (day < 10) day = `0${day}`; if (day < 10) day = `0${day}`;

View File

@ -4,7 +4,7 @@ import getBrowser from '../../helpers/puppeteer';
describe('Travel create path', () => { describe('Travel create path', () => {
let browser; let browser;
let page; let page;
const date = new Date(); const date = new Date('2022-01-19');
const day = 15; const day = 15;
date.setDate(day); date.setDate(day);

View File

@ -22,7 +22,7 @@ describe('Travel basic data path', () => {
}); });
it('should set a wrong delivery date then receive an error on submit', async() => { it('should set a wrong delivery date then receive an error on submit', async() => {
const lastMonth = new Date(); const lastMonth = new Date('2022-01-19');
lastMonth.setMonth(lastMonth.getMonth() - 1); lastMonth.setMonth(lastMonth.getMonth() - 1);
await page.pickDate(selectors.travelBasicData.deliveryDate, lastMonth); await page.pickDate(selectors.travelBasicData.deliveryDate, lastMonth);

View File

@ -123,7 +123,7 @@ describe('Travel descriptor path', () => {
}); });
it('should update the landed date to a future date to enable cloneWithEntries', async() => { it('should update the landed date to a future date to enable cloneWithEntries', async() => {
const nextMonth = new Date(); const nextMonth = new Date('2022-01-19');
nextMonth.setMonth(nextMonth.getMonth() + 1); nextMonth.setMonth(nextMonth.getMonth() + 1);
await page.pickDate(selectors.travelBasicData.deliveryDate, nextMonth); await page.pickDate(selectors.travelBasicData.deliveryDate, nextMonth);
await page.waitToClick(selectors.travelBasicData.save); await page.waitToClick(selectors.travelBasicData.save);

View File

@ -2,7 +2,7 @@ describe('Component vnCalendar', () => {
let controller; let controller;
let $element; let $element;
let date = new Date(); let date = new Date('2022-01-19');
date.setHours(0, 0, 0, 0); date.setHours(0, 0, 0, 0);
date.setDate(1); date.setDate(1);
@ -48,7 +48,7 @@ describe('Component vnCalendar', () => {
it(`should return the selected element, then emit a 'selection' event`, () => { it(`should return the selected element, then emit a 'selection' event`, () => {
jest.spyOn(controller, 'emit'); jest.spyOn(controller, 'emit');
const day = new Date(); const day = new Date('2022-01-19');
day.setHours(0, 0, 0, 0); day.setHours(0, 0, 0, 0);
const clickEvent = new Event('click'); const clickEvent = new Event('click');

View File

@ -4,7 +4,7 @@ describe('Component vnDatePicker', () => {
let $ctrl; let $ctrl;
let today; let today;
today = new Date(); today = new Date('2022-01-19');
today.setHours(0, 0, 0, 0); today.setHours(0, 0, 0, 0);
beforeEach(ngModule('vnCore')); beforeEach(ngModule('vnCore'));

View File

@ -20,7 +20,7 @@ describe('Component vnInputTime', () => {
describe('field() setter', () => { describe('field() setter', () => {
it(`should display the formated the date`, () => { it(`should display the formated the date`, () => {
let date = new Date(); let date = new Date('2022-01-19');
$ctrl.field = date; $ctrl.field = date;
let displayed = $filter('date')(date, 'HH:mm'); let displayed = $filter('date')(date, 'HH:mm');

View File

@ -54,7 +54,7 @@ describe('Claim createFromSales()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const todayMinusEightDays = new Date(); const todayMinusEightDays = new Date('2022-01-19');
todayMinusEightDays.setDate(todayMinusEightDays.getDate() - 8); todayMinusEightDays.setDate(todayMinusEightDays.getDate() - 8);
const ticket = await models.Ticket.findById(ticketId, null, options); const ticket = await models.Ticket.findById(ticketId, null, options);
@ -85,7 +85,7 @@ describe('Claim createFromSales()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const todayMinusEightDays = new Date(); const todayMinusEightDays = new Date('2022-01-19');
todayMinusEightDays.setDate(todayMinusEightDays.getDate() - 8); todayMinusEightDays.setDate(todayMinusEightDays.getDate() - 8);
const ticket = await models.Ticket.findById(ticketId, null, options); const ticket = await models.Ticket.findById(ticketId, null, options);

View File

@ -1,7 +1,7 @@
const app = require('vn-loopback/server/server'); const app = require('vn-loopback/server/server');
describe('Update Claim', () => { describe('Update Claim', () => {
const newDate = new Date(); const newDate = new Date('2022-01-19');
const originalData = { const originalData = {
ticketFk: 3, ticketFk: 3,
clientFk: 1101, clientFk: 1101,

View File

@ -1,7 +1,7 @@
const app = require('vn-loopback/server/server'); const app = require('vn-loopback/server/server');
describe('Update Claim', () => { describe('Update Claim', () => {
const newDate = new Date(); const newDate = new Date('2022-01-19');
const original = { const original = {
ticketFk: 3, ticketFk: 3,
clientFk: 1101, clientFk: 1101,

View File

@ -26,7 +26,7 @@ describe('Client', () => {
it('should call the window.open function', () => { it('should call the window.open function', () => {
jest.spyOn(window, 'open').mockReturnThis(); jest.spyOn(window, 'open').mockReturnThis();
const now = new Date(); const now = new Date('2022-01-19');
controller.$.model.userParams = { controller.$.model.userParams = {
from: now, from: now,
to: now to: now
@ -48,7 +48,7 @@ describe('Client', () => {
describe('sendEmail()', () => { describe('sendEmail()', () => {
it('should make a GET query sending the report', () => { it('should make a GET query sending the report', () => {
const now = new Date(); const now = new Date('2022-01-19');
controller.$.model.userParams = { controller.$.model.userParams = {
from: now, from: now,
to: now to: now

View File

@ -24,7 +24,7 @@ describe('Client', () => {
describe('onSubmit()', () => { describe('onSubmit()', () => {
it('should perform a POST query', () => { it('should perform a POST query', () => {
let started = new Date(); let started = new Date('2022-01-19');
controller.creditClassification = { controller.creditClassification = {
started: started, started: started,
credit: 300, credit: 300,

View File

@ -49,14 +49,14 @@ describe('client defaulter', () => {
describe('chipColor()', () => { describe('chipColor()', () => {
it('should return undefined when the date is the present', () => { it('should return undefined when the date is the present', () => {
let today = new Date(); let today = new Date('2022-01-19');
let result = controller.chipColor(today); let result = controller.chipColor(today);
expect(result).toEqual(undefined); expect(result).toEqual(undefined);
}); });
it('should return warning when the date is 10 days in the past', () => { it('should return warning when the date is 10 days in the past', () => {
let pastDate = new Date(); let pastDate = new Date('2022-01-19');
pastDate = pastDate.setDate(pastDate.getDate() - 11); pastDate = pastDate.setDate(pastDate.getDate() - 11);
let result = controller.chipColor(pastDate); let result = controller.chipColor(pastDate);
@ -64,7 +64,7 @@ describe('client defaulter', () => {
}); });
it('should return alert when the date is 20 days in the past', () => { it('should return alert when the date is 20 days in the past', () => {
let pastDate = new Date(); let pastDate = new Date('2022-01-19');
pastDate = pastDate.setDate(pastDate.getDate() - 21); pastDate = pastDate.setDate(pastDate.getDate() - 21);
let result = controller.chipColor(pastDate); let result = controller.chipColor(pastDate);

View File

@ -39,7 +39,7 @@ describe('Client notification', () => {
describe('campaignSelection() setter', () => { describe('campaignSelection() setter', () => {
it('should set the campaign from and to properties', () => { it('should set the campaign from and to properties', () => {
const dated = new Date(); const dated = new Date('2022-01-19');
controller.campaignSelection = { controller.campaignSelection = {
dated: dated, dated: dated,
scopeDays: 14 scopeDays: 14
@ -62,8 +62,8 @@ describe('Client notification', () => {
controller.$.filters = {hide: () => {}}; controller.$.filters = {hide: () => {}};
controller.campaign = { controller.campaign = {
id: 1, id: 1,
from: new Date(), from: new Date('2022-01-19'),
to: new Date() to: new Date('2022-01-19')
}; };
const data = controller.$.model.data; const data = controller.$.model.data;

View File

@ -76,14 +76,14 @@ describe('Client', () => {
describe('chipColor()', () => { describe('chipColor()', () => {
it('should return warning when the date is the present', () => { it('should return warning when the date is the present', () => {
let today = new Date(); let today = new Date('2022-01-19');
let result = controller.chipColor(today); let result = controller.chipColor(today);
expect(result).toEqual('warning'); expect(result).toEqual('warning');
}); });
it('should return success when the date is in the future', () => { it('should return success when the date is in the future', () => {
let futureDate = new Date(); let futureDate = new Date('2022-01-19');
futureDate = futureDate.setDate(futureDate.getDate() + 10); futureDate = futureDate.setDate(futureDate.getDate() + 10);
let result = controller.chipColor(futureDate); let result = controller.chipColor(futureDate);
@ -91,7 +91,7 @@ describe('Client', () => {
}); });
it('should return undefined when the date is in the past', () => { it('should return undefined when the date is in the past', () => {
let pastDate = new Date(); let pastDate = new Date('2022-01-19');
pastDate = pastDate.setDate(pastDate.getDate() - 10); pastDate = pastDate.setDate(pastDate.getDate() - 10);
let result = controller.chipColor(pastDate); let result = controller.chipColor(pastDate);

View File

@ -318,10 +318,10 @@ describe('Entry latests buys filter()', () => {
const options = {transaction: tx}; const options = {transaction: tx};
try { try {
const from = new Date(); const from = new Date('2022-01-19');
from.setHours(0, 0, 0, 0); from.setHours(0, 0, 0, 0);
const to = new Date(); const to = new Date('2022-01-19');
to.setHours(23, 59, 59, 999); to.setHours(23, 59, 59, 999);
const ctx = { const ctx = {

View File

@ -146,8 +146,8 @@ describe('InvoiceIn filter()', () => {
const options = {transaction: tx}; const options = {transaction: tx};
try { try {
const from = new Date(); const from = new Date('2022-01-19');
const to = new Date(); const to = new Date('2022-01-19');
from.setHours(0, 0, 0, 0); from.setHours(0, 0, 0, 0);
to.setHours(23, 59, 59, 999); to.setHours(23, 59, 59, 999);
to.setDate(to.getDate() + 1); to.setDate(to.getDate() + 1);

View File

@ -1,7 +1,7 @@
const models = require('vn-loopback/server/server').models; const models = require('vn-loopback/server/server').models;
describe('InvoiceOut filter()', () => { describe('InvoiceOut filter()', () => {
let today = new Date(); let today = new Date('2022-01-19');
today.setHours(2, 0, 0, 0); today.setHours(2, 0, 0, 0);
it('should return the invoice out matching ref', async() => { it('should return the invoice out matching ref', async() => {

View File

@ -19,8 +19,8 @@ describe('InvoiceOut globalInvoicing()', () => {
try { try {
ctx.args = { ctx.args = {
invoiceDate: new Date(), invoiceDate: new Date('2022-01-19'),
maxShipped: new Date(), maxShipped: new Date('2022-01-19'),
fromClientId: clientId, fromClientId: clientId,
toClientId: clientId, toClientId: clientId,
companyFk: companyFk companyFk: companyFk

View File

@ -73,8 +73,8 @@ describe('InvoiceOut', () => {
jest.spyOn(controller.vnApp, 'showError'); jest.spyOn(controller.vnApp, 'showError');
controller.invoice = { controller.invoice = {
invoiceDate: new Date(), invoiceDate: new Date('2022-01-19'),
maxShipped: new Date() maxShipped: new Date('2022-01-19')
}; };
controller.responseHandler('accept'); controller.responseHandler('accept');
@ -86,8 +86,8 @@ describe('InvoiceOut', () => {
jest.spyOn(controller.vnApp, 'showSuccess'); jest.spyOn(controller.vnApp, 'showSuccess');
controller.invoice = { controller.invoice = {
invoiceDate: new Date(), invoiceDate: new Date('2022-01-19'),
maxShipped: new Date(), maxShipped: new Date('2022-01-19'),
fromClientId: 1101, fromClientId: 1101,
toClientId: 1101 toClientId: 1101
}; };

View File

@ -1,7 +1,7 @@
const models = require('vn-loopback/server/server').models; const models = require('vn-loopback/server/server').models;
describe('upsertFixedPrice()', () => { describe('upsertFixedPrice()', () => {
const now = new Date(); const now = new Date('2022-01-19');
const fixedPriceId = 1; const fixedPriceId = 1;
let originalFixedPrice; let originalFixedPrice;

View File

@ -8,7 +8,7 @@ describe('item getVisibleAvailable()', () => {
try { try {
const itemFk = 1; const itemFk = 1;
const warehouseFk = 1; const warehouseFk = 1;
const dated = new Date(); const dated = new Date('2022-01-19');
const result = await models.Item.getVisibleAvailable(itemFk, warehouseFk, dated, options); const result = await models.Item.getVisibleAvailable(itemFk, warehouseFk, dated, options);
@ -29,7 +29,7 @@ describe('item getVisibleAvailable()', () => {
try { try {
const itemFk = 1; const itemFk = 1;
const warehouseFk = 1; const warehouseFk = 1;
const dated = new Date(); const dated = new Date('2022-01-19');
dated.setDate(dated.getDate() - 1); dated.setDate(dated.getDate() - 1);
const result = await models.Item.getVisibleAvailable(itemFk, warehouseFk, dated, options); const result = await models.Item.getVisibleAvailable(itemFk, warehouseFk, dated, options);

View File

@ -24,7 +24,7 @@ describe('fixed price', () => {
}); });
it('should perform an http request to update the price', () => { it('should perform an http request to update the price', () => {
const now = new Date(); const now = new Date('2022-01-19');
jest.spyOn(controller.vnApp, 'showSuccess'); jest.spyOn(controller.vnApp, 'showSuccess');
$httpBackend.expectPATCH('FixedPrices/upsertFixedPrice').respond(); $httpBackend.expectPATCH('FixedPrices/upsertFixedPrice').respond();

View File

@ -15,7 +15,7 @@ describe(' Component vnRequestSearchPanel', () => {
it('should clear the scope days when setting the from property', () => { it('should clear the scope days when setting the from property', () => {
controller.filter.scopeDays = 1; controller.filter.scopeDays = 1;
controller.from = new Date(); controller.from = new Date('2022-01-19');
expect(controller.filter.scopeDays).toBeNull(); expect(controller.filter.scopeDays).toBeNull();
expect(controller.from).toBeDefined(); expect(controller.from).toBeDefined();
@ -26,7 +26,7 @@ describe(' Component vnRequestSearchPanel', () => {
it('should clear the scope days when setting the to property', () => { it('should clear the scope days when setting the to property', () => {
controller.filter.scopeDays = 1; controller.filter.scopeDays = 1;
controller.to = new Date(); controller.to = new Date('2022-01-19');
expect(controller.filter.scopeDays).toBeNull(); expect(controller.filter.scopeDays).toBeNull();
expect(controller.to).toBeDefined(); expect(controller.to).toBeDefined();
@ -35,8 +35,8 @@ describe(' Component vnRequestSearchPanel', () => {
describe('scopeDays() setter', () => { describe('scopeDays() setter', () => {
it('should clear the date range when setting the scopeDays property', () => { it('should clear the date range when setting the scopeDays property', () => {
controller.filter.from = new Date(); controller.filter.from = new Date('2022-01-19');
controller.filter.to = new Date(); controller.filter.to = new Date('2022-01-19');
controller.scopeDays = 1; controller.scopeDays = 1;

View File

@ -93,7 +93,7 @@ describe('Item', () => {
}); });
it(`should return "warning" if date is today`, () => { it(`should return "warning" if date is today`, () => {
let date = new Date(); let date = new Date('2022-01-19');
let result = controller.compareDate(date); let result = controller.compareDate(date);
expect(result).toEqual('warning'); expect(result).toEqual('warning');

View File

@ -26,9 +26,9 @@ describe('SalesMonitor salesFilter()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const yesterday = new Date(); const yesterday = new Date('2022-01-19');
yesterday.setHours(0, 0, 0, 0); yesterday.setHours(0, 0, 0, 0);
const today = new Date(); const today = new Date('2022-01-19');
today.setHours(23, 59, 59, 59); today.setHours(23, 59, 59, 59);
const ctx = {req: {accessToken: {userId: 9}}, args: { const ctx = {req: {accessToken: {userId: 9}}, args: {
@ -54,10 +54,10 @@ describe('SalesMonitor salesFilter()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const yesterday = new Date(); const yesterday = new Date('2022-01-19');
yesterday.setDate(yesterday.getDate() - 1); yesterday.setDate(yesterday.getDate() - 1);
yesterday.setHours(0, 0, 0, 0); yesterday.setHours(0, 0, 0, 0);
const today = new Date(); const today = new Date('2022-01-19');
today.setHours(23, 59, 59, 59); today.setHours(23, 59, 59, 59);
const ctx = {req: {accessToken: {userId: 9}}, args: { const ctx = {req: {accessToken: {userId: 9}}, args: {
@ -209,10 +209,10 @@ describe('SalesMonitor salesFilter()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const yesterday = new Date(); const yesterday = new Date('2022-01-19');
yesterday.setDate(yesterday.getDate() - 1); yesterday.setDate(yesterday.getDate() - 1);
yesterday.setHours(0, 0, 0, 0); yesterday.setHours(0, 0, 0, 0);
const today = new Date(); const today = new Date('2022-01-19');
today.setHours(23, 59, 59, 59); today.setHours(23, 59, 59, 59);
const ctx = {req: {accessToken: {userId: 18}}, args: {}}; const ctx = {req: {accessToken: {userId: 18}}, args: {}};
@ -238,10 +238,10 @@ describe('SalesMonitor salesFilter()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const yesterday = new Date(); const yesterday = new Date('2022-01-19');
yesterday.setDate(yesterday.getDate() - 1); yesterday.setDate(yesterday.getDate() - 1);
yesterday.setHours(0, 0, 0, 0); yesterday.setHours(0, 0, 0, 0);
const today = new Date(); const today = new Date('2022-01-19');
today.setHours(23, 59, 59, 59); today.setHours(23, 59, 59, 59);
const ctx = {req: {accessToken: {userId: 18}}, args: {}}; const ctx = {req: {accessToken: {userId: 18}}, args: {}};

View File

@ -38,7 +38,7 @@ describe('Monitor Component vnMonitorSalesSearchPanel', () => {
it('should clear the scope days when setting the from property', () => { it('should clear the scope days when setting the from property', () => {
controller.filter.scopeDays = 1; controller.filter.scopeDays = 1;
controller.from = new Date(); controller.from = new Date('2022-01-19');
expect(controller.filter.scopeDays).toBeNull(); expect(controller.filter.scopeDays).toBeNull();
expect(controller.from).toBeDefined(); expect(controller.from).toBeDefined();
@ -49,7 +49,7 @@ describe('Monitor Component vnMonitorSalesSearchPanel', () => {
it('should clear the scope days when setting the to property', () => { it('should clear the scope days when setting the to property', () => {
controller.filter.scopeDays = 1; controller.filter.scopeDays = 1;
controller.to = new Date(); controller.to = new Date('2022-01-19');
expect(controller.filter.scopeDays).toBeNull(); expect(controller.filter.scopeDays).toBeNull();
expect(controller.to).toBeDefined(); expect(controller.to).toBeDefined();
@ -58,8 +58,8 @@ describe('Monitor Component vnMonitorSalesSearchPanel', () => {
describe('scopeDays() setter', () => { describe('scopeDays() setter', () => {
it('should clear the date range when setting the scopeDays property', () => { it('should clear the date range when setting the scopeDays property', () => {
controller.filter.from = new Date(); controller.filter.from = new Date('2022-01-19');
controller.filter.to = new Date(); controller.filter.to = new Date('2022-01-19');
controller.scopeDays = 1; controller.scopeDays = 1;

View File

@ -32,7 +32,7 @@ describe('Component vnMonitorSalesTickets', () => {
let params = controller.fetchParams({ let params = controller.fetchParams({
scopeDays: 2 scopeDays: 2
}); });
const from = new Date(); const from = new Date('2022-01-19');
from.setHours(0, 0, 0, 0); from.setHours(0, 0, 0, 0);
const to = new Date(from.getTime()); const to = new Date(from.getTime());
to.setDate(to.getDate() + params.scopeDays); to.setDate(to.getDate() + params.scopeDays);
@ -66,14 +66,14 @@ describe('Component vnMonitorSalesTickets', () => {
describe('compareDate()', () => { describe('compareDate()', () => {
it('should return warning when the date is the present', () => { it('should return warning when the date is the present', () => {
let today = new Date(); let today = new Date('2022-01-19');
let result = controller.compareDate(today); let result = controller.compareDate(today);
expect(result).toEqual('warning'); expect(result).toEqual('warning');
}); });
it('should return sucess when the date is in the future', () => { it('should return sucess when the date is in the future', () => {
let futureDate = new Date(); let futureDate = new Date('2022-01-19');
futureDate = futureDate.setDate(futureDate.getDate() + 10); futureDate = futureDate.setDate(futureDate.getDate() + 10);
let result = controller.compareDate(futureDate); let result = controller.compareDate(futureDate);
@ -81,7 +81,7 @@ describe('Component vnMonitorSalesTickets', () => {
}); });
it('should return undefined when the date is in the past', () => { it('should return undefined when the date is in the past', () => {
let pastDate = new Date(); let pastDate = new Date('2022-01-19');
pastDate = pastDate.setDate(pastDate.getDate() - 10); pastDate = pastDate.setDate(pastDate.getDate() - 10);
let result = controller.compareDate(pastDate); let result = controller.compareDate(pastDate);
@ -99,7 +99,7 @@ describe('Component vnMonitorSalesTickets', () => {
describe('dateRange()', () => { describe('dateRange()', () => {
it('should return two dates with the hours at the start and end of the given date', () => { it('should return two dates with the hours at the start and end of the given date', () => {
const now = new Date(); const now = new Date('2022-01-19');
const today = now.getDate(); const today = now.getDate();

View File

@ -9,7 +9,7 @@ describe('order new()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const landed = new Date(); const landed = new Date('2022-01-19');
const addressFk = 6; const addressFk = 6;
const agencyModeFk = 1; const agencyModeFk = 1;
@ -30,7 +30,7 @@ describe('order new()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const landed = new Date(); const landed = new Date('2022-01-19');
const addressFk = 121; const addressFk = 121;
const agencyModeFk = 1; const agencyModeFk = 1;

View File

@ -46,7 +46,7 @@ describe('Order', () => {
it('should set agencyModeFk to null and get the available agencies if the order has landed and client', async() => { it('should set agencyModeFk to null and get the available agencies if the order has landed and client', async() => {
controller.order.agencyModeFk = 999; controller.order.agencyModeFk = 999;
controller.order.addressFk = 999; controller.order.addressFk = 999;
controller.order.landed = new Date(); controller.order.landed = new Date('2022-01-19');
const expectedAgencies = [{id: 1}, {id: 2}]; const expectedAgencies = [{id: 1}, {id: 2}];

View File

@ -26,14 +26,14 @@ describe('Component vnOrderIndex', () => {
describe('compareDate()', () => { describe('compareDate()', () => {
it('should return warning when the date is the present', () => { it('should return warning when the date is the present', () => {
let curDate = new Date(); let curDate = new Date('2022-01-19');
let result = controller.compareDate(curDate); let result = controller.compareDate(curDate);
expect(result).toEqual('warning'); expect(result).toEqual('warning');
}); });
it('should return sucess when the date is in the future', () => { it('should return sucess when the date is in the future', () => {
let futureDate = new Date(); let futureDate = new Date('2022-01-19');
futureDate = futureDate.setDate(futureDate.getDate() + 10); futureDate = futureDate.setDate(futureDate.getDate() + 10);
let result = controller.compareDate(futureDate); let result = controller.compareDate(futureDate);
@ -41,7 +41,7 @@ describe('Component vnOrderIndex', () => {
}); });
it('should return undefined when the date is in the past', () => { it('should return undefined when the date is in the past', () => {
let pastDate = new Date(); let pastDate = new Date('2022-01-19');
pastDate = pastDate.setDate(pastDate.getDate() - 10); pastDate = pastDate.setDate(pastDate.getDate() - 10);
let result = controller.compareDate(pastDate); let result = controller.compareDate(pastDate);

View File

@ -3,7 +3,7 @@ const models = require('vn-loopback/server/server').models;
describe('AgencyTerm filter()', () => { describe('AgencyTerm filter()', () => {
const authUserId = 9; const authUserId = 9;
const today = new Date(); const today = new Date('2022-01-19');
today.setHours(2, 0, 0, 0); today.setHours(2, 0, 0, 0);
it('should return all results matching the filter', async() => { it('should return all results matching the filter', async() => {
@ -57,10 +57,10 @@ describe('AgencyTerm filter()', () => {
const options = {transaction: tx}; const options = {transaction: tx};
try { try {
const from = new Date(); const from = new Date('2022-01-19');
from.setHours(0, 0, 0, 0); from.setHours(0, 0, 0, 0);
const to = new Date(); const to = new Date('2022-01-19');
to.setHours(23, 59, 59, 999); to.setHours(23, 59, 59, 999);
const ctx = { const ctx = {

View File

@ -1,7 +1,7 @@
const app = require('vn-loopback/server/server'); const app = require('vn-loopback/server/server');
describe('route clone()', () => { describe('route clone()', () => {
const createdDate = new Date(); const createdDate = new Date('2022-01-19');
it('should throw an error if the amount of ids pased to the clone function do no match the database', async() => { it('should throw an error if the amount of ids pased to the clone function do no match the database', async() => {
const ids = [996, 997, 998, 999]; const ids = [996, 997, 998, 999];

View File

@ -2,7 +2,7 @@ const app = require('vn-loopback/server/server');
const models = require('vn-loopback/server/server').models; const models = require('vn-loopback/server/server').models;
describe('Route filter()', () => { describe('Route filter()', () => {
let today = new Date(); let today = new Date('2022-01-19');
today.setHours(2, 0, 0, 0); today.setHours(2, 0, 0, 0);
it('should return the routes matching "search"', async() => { it('should return the routes matching "search"', async() => {
@ -23,10 +23,10 @@ describe('Route filter()', () => {
const options = {transaction: tx}; const options = {transaction: tx};
try { try {
const from = new Date(); const from = new Date('2022-01-19');
from.setHours(0, 0, 0, 0); from.setHours(0, 0, 0, 0);
const to = new Date(); const to = new Date('2022-01-19');
to.setHours(23, 59, 59, 999); to.setHours(23, 59, 59, 999);
const ctx = { const ctx = {

View File

@ -21,7 +21,7 @@ describe('route getSuggestedTickets()', () => {
await ticketInRoute.updateAttributes({ await ticketInRoute.updateAttributes({
routeFk: null, routeFk: null,
landed: new Date() landed: new Date('2022-01-19')
}, options); }, options);
const result = await app.models.Route.getSuggestedTickets(routeID, options); const result = await app.models.Route.getSuggestedTickets(routeID, options);

View File

@ -23,7 +23,7 @@ describe('route insertTicket()', () => {
const ticketInRoute = await app.models.Ticket.findById(ticketId, null, options); const ticketInRoute = await app.models.Ticket.findById(ticketId, null, options);
await ticketInRoute.updateAttributes({ await ticketInRoute.updateAttributes({
routeFk: null, routeFk: null,
landed: new Date() landed: new Date('2022-01-19')
}, options); }, options);
const result = await app.models.Route.insertTicket(routeId, ticketId, options); const result = await app.models.Route.insertTicket(routeId, ticketId, options);

View File

@ -62,7 +62,7 @@ describe('Component vnRouteIndex', () => {
describe('cloneSelectedRoutes()', () => { describe('cloneSelectedRoutes()', () => {
it('should perform an http request to Routes/clone', () => { it('should perform an http request to Routes/clone', () => {
controller.createdDate = new Date(); controller.createdDate = new Date('2022-01-19');
$httpBackend.expect('POST', 'Routes/clone').respond(); $httpBackend.expect('POST', 'Routes/clone').respond();
controller.cloneSelectedRoutes(); controller.cloneSelectedRoutes();

View File

@ -15,7 +15,7 @@ describe('Route Component vnRoute', () => {
let params = controller.fetchParams({ let params = controller.fetchParams({
scopeDays: 2 scopeDays: 2
}); });
const from = new Date(); const from = new Date('2022-01-19');
from.setHours(0, 0, 0, 0); from.setHours(0, 0, 0, 0);
const to = new Date(from.getTime()); const to = new Date(from.getTime());
to.setDate(to.getDate() + params.scopeDays); to.setDate(to.getDate() + params.scopeDays);

View File

@ -15,7 +15,7 @@ describe('Route Component vnRouteSearchPanel', () => {
it('should clear the scope days when setting the from property', () => { it('should clear the scope days when setting the from property', () => {
controller.filter.scopeDays = 1; controller.filter.scopeDays = 1;
controller.from = new Date(); controller.from = new Date('2022-01-19');
expect(controller.filter.scopeDays).toBeNull(); expect(controller.filter.scopeDays).toBeNull();
expect(controller.from).toBeDefined(); expect(controller.from).toBeDefined();
@ -26,7 +26,7 @@ describe('Route Component vnRouteSearchPanel', () => {
it('should clear the scope days when setting the to property', () => { it('should clear the scope days when setting the to property', () => {
controller.filter.scopeDays = 1; controller.filter.scopeDays = 1;
controller.to = new Date(); controller.to = new Date('2022-01-19');
expect(controller.filter.scopeDays).toBeNull(); expect(controller.filter.scopeDays).toBeNull();
expect(controller.to).toBeDefined(); expect(controller.to).toBeDefined();
@ -35,8 +35,8 @@ describe('Route Component vnRouteSearchPanel', () => {
describe('scopeDays() setter', () => { describe('scopeDays() setter', () => {
it('should clear the date range when setting the scopeDays property', () => { it('should clear the date range when setting the scopeDays property', () => {
controller.filter.from = new Date(); controller.filter.from = new Date('2022-01-19');
controller.filter.to = new Date(); controller.filter.to = new Date('2022-01-19');
controller.scopeDays = 1; controller.scopeDays = 1;

View File

@ -28,7 +28,7 @@ describe('Supplier', () => {
it('should call the window.open function', () => { it('should call the window.open function', () => {
jest.spyOn(window, 'open').mockReturnThis(); jest.spyOn(window, 'open').mockReturnThis();
const now = new Date(); const now = new Date('2022-01-19');
controller.$.model.userParams = { controller.$.model.userParams = {
from: now, from: now,
to: now to: now
@ -85,7 +85,7 @@ describe('Supplier', () => {
{id: 1, email: 'batman@gothamcity.com'} {id: 1, email: 'batman@gothamcity.com'}
]); ]);
const now = new Date(); const now = new Date('2022-01-19');
controller.$.model.userParams = { controller.$.model.userParams = {
from: now, from: now,
to: now to: now

View File

@ -9,7 +9,7 @@ describe('ticket changeState()', () => {
accessToken: {userId: 9}, accessToken: {userId: 9},
}; };
const ctx = {req: activeCtx}; const ctx = {req: activeCtx};
const now = new Date(); const now = new Date('2022-01-19');
const sampleTicket = { const sampleTicket = {
shipped: now, shipped: now,
landed: now, landed: now,

View File

@ -62,7 +62,7 @@ describe('ticket canBeInvoiced()', () => {
const ticket = await models.Ticket.findById(ticketId, null, options); const ticket = await models.Ticket.findById(ticketId, null, options);
const shipped = new Date(); const shipped = new Date('2022-01-19');
shipped.setDate(shipped.getDate() + 1); shipped.setDate(shipped.getDate() + 1);
await ticket.updateAttribute('shipped', shipped, options); await ticket.updateAttribute('shipped', shipped, options);

View File

@ -3,8 +3,8 @@ const models = require('vn-loopback/server/server').models;
describe('ticket componentUpdate()', () => { describe('ticket componentUpdate()', () => {
const userID = 1101; const userID = 1101;
const ticketID = 11; const ticketID = 11;
const today = new Date(); const today = new Date('2022-01-19');
const tomorrow = new Date(); const tomorrow = new Date('2022-01-19');
tomorrow.setDate(tomorrow.getDate() + 1); tomorrow.setDate(tomorrow.getDate() + 1);

View File

@ -26,9 +26,9 @@ describe('ticket filter()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const yesterday = new Date(); const yesterday = new Date('2022-01-19');
yesterday.setHours(0, 0, 0, 0); yesterday.setHours(0, 0, 0, 0);
const today = new Date(); const today = new Date('2022-01-19');
today.setHours(23, 59, 59, 59); today.setHours(23, 59, 59, 59);
const ctx = {req: {accessToken: {userId: 9}}, args: { const ctx = {req: {accessToken: {userId: 9}}, args: {
@ -54,10 +54,10 @@ describe('ticket filter()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const yesterday = new Date(); const yesterday = new Date('2022-01-19');
yesterday.setDate(yesterday.getDate() - 1); yesterday.setDate(yesterday.getDate() - 1);
yesterday.setHours(0, 0, 0, 0); yesterday.setHours(0, 0, 0, 0);
const today = new Date(); const today = new Date('2022-01-19');
today.setHours(23, 59, 59, 59); today.setHours(23, 59, 59, 59);
const ctx = {req: {accessToken: {userId: 9}}, args: { const ctx = {req: {accessToken: {userId: 9}}, args: {

View File

@ -2,7 +2,7 @@ const models = require('vn-loopback/server/server').models;
let UserError = require('vn-loopback/util/user-error'); let UserError = require('vn-loopback/util/user-error');
describe('ticket new()', () => { describe('ticket new()', () => {
const today = new Date(); const today = new Date('2022-01-19');
const ctx = {req: {accessToken: {userId: 1}}}; const ctx = {req: {accessToken: {userId: 1}}};
it('should throw an error if the client isnt frozen and isnt active', async() => { it('should throw an error if the client isnt frozen and isnt active', async() => {

View File

@ -8,7 +8,7 @@ describe('sale priceDifference()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const tomorrow = new Date(); const tomorrow = new Date('2022-01-19');
tomorrow.setDate(tomorrow.getDate() + 1); tomorrow.setDate(tomorrow.getDate() + 1);
const ctx = {req: {accessToken: {userId: 1106}}}; const ctx = {req: {accessToken: {userId: 1106}}};
@ -45,8 +45,8 @@ describe('sale priceDifference()', () => {
const ctx = {req: {accessToken: {userId: 1106}}}; const ctx = {req: {accessToken: {userId: 1106}}};
ctx.args = { ctx.args = {
id: 1, id: 1,
landed: new Date(), landed: new Date('2022-01-19'),
shipped: new Date(), shipped: new Date('2022-01-19'),
addressId: 121, addressId: 121,
zoneId: 3, zoneId: 3,
warehouseId: 1 warehouseId: 1
@ -68,7 +68,7 @@ describe('sale priceDifference()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const tomorrow = new Date(); const tomorrow = new Date('2022-01-19');
tomorrow.setDate(tomorrow.getDate() + 1); tomorrow.setDate(tomorrow.getDate() + 1);
const ctx = {req: {accessToken: {userId: 1106}}}; const ctx = {req: {accessToken: {userId: 1106}}};

View File

@ -24,7 +24,7 @@ describe('ticket restore()', () => {
let error; let error;
const tx = await app.models.Ticket.beginTransaction({}); const tx = await app.models.Ticket.beginTransaction({});
const now = new Date(); const now = new Date('2022-01-19');
now.setHours(now.getHours() - 1); now.setHours(now.getHours() - 1);
try { try {
@ -46,7 +46,7 @@ describe('ticket restore()', () => {
it('should restore the ticket making its state no longer deleted', async() => { it('should restore the ticket making its state no longer deleted', async() => {
const tx = await app.models.Ticket.beginTransaction({}); const tx = await app.models.Ticket.beginTransaction({});
const now = new Date(); const now = new Date('2022-01-19');
try { try {
const options = {transaction: tx}; const options = {transaction: tx};

View File

@ -67,7 +67,7 @@ describe('Ticket', () => {
jest.spyOn(controller, 'getShipped'); jest.spyOn(controller, 'getShipped');
controller.ticket.addressFk = 99; controller.ticket.addressFk = 99;
controller.addressId = 100; controller.addressId = 100;
const landed = new Date(); const landed = new Date('2022-01-19');
const expectedResult = { const expectedResult = {
landed: landed, landed: landed,
addressFk: 100, addressFk: 100,
@ -101,7 +101,7 @@ describe('Ticket', () => {
describe('shipped() getter', () => { describe('shipped() getter', () => {
it('should return the shipped property', () => { it('should return the shipped property', () => {
const shipped = new Date(); const shipped = new Date('2022-01-19');
controller.ticket.shipped = shipped; controller.ticket.shipped = shipped;
expect(controller.shipped).toEqual(shipped); expect(controller.shipped).toEqual(shipped);
@ -111,7 +111,7 @@ describe('Ticket', () => {
describe('shipped() setter', () => { describe('shipped() setter', () => {
it('should set shipped property and call getLanded() method ', () => { it('should set shipped property and call getLanded() method ', () => {
jest.spyOn(controller, 'getLanded'); jest.spyOn(controller, 'getLanded');
const shipped = new Date(); const shipped = new Date('2022-01-19');
const expectedResult = { const expectedResult = {
shipped: shipped, shipped: shipped,
addressFk: 121, addressFk: 121,
@ -126,7 +126,7 @@ describe('Ticket', () => {
describe('landed() getter', () => { describe('landed() getter', () => {
it('should return the landed property', () => { it('should return the landed property', () => {
const landed = new Date(); const landed = new Date('2022-01-19');
controller.ticket.landed = landed; controller.ticket.landed = landed;
expect(controller.landed).toEqual(landed); expect(controller.landed).toEqual(landed);
@ -136,7 +136,7 @@ describe('Ticket', () => {
describe('landed() setter', () => { describe('landed() setter', () => {
it('should set shipped property and call getShipped() method ', () => { it('should set shipped property and call getShipped() method ', () => {
jest.spyOn(controller, 'getShipped'); jest.spyOn(controller, 'getShipped');
const landed = new Date(); const landed = new Date('2022-01-19');
const expectedResult = { const expectedResult = {
landed: landed, landed: landed,
addressFk: 121, addressFk: 121,
@ -161,7 +161,7 @@ describe('Ticket', () => {
it('should set agencyModeId property and call getLanded() method', () => { it('should set agencyModeId property and call getLanded() method', () => {
jest.spyOn(controller, 'getLanded'); jest.spyOn(controller, 'getLanded');
controller.$.agencyMode = {selection: {warehouseFk: 1}}; controller.$.agencyMode = {selection: {warehouseFk: 1}};
const shipped = new Date(); const shipped = new Date('2022-01-19');
const agencyModeId = 8; const agencyModeId = 8;
const expectedResult = { const expectedResult = {
shipped: shipped, shipped: shipped,
@ -177,7 +177,7 @@ describe('Ticket', () => {
it('should do nothing if attempting to set the same agencyMode id', () => { it('should do nothing if attempting to set the same agencyMode id', () => {
jest.spyOn(controller, 'getShipped'); jest.spyOn(controller, 'getShipped');
const landed = new Date(); const landed = new Date('2022-01-19');
const agencyModeId = 7; const agencyModeId = 7;
const expectedResult = { const expectedResult = {
landed: landed, landed: landed,
@ -278,8 +278,8 @@ describe('Ticket', () => {
agencyModeFk: 1, agencyModeFk: 1,
companyFk: 442, companyFk: 442,
warehouseFk: 1, warehouseFk: 1,
shipped: new Date(), shipped: new Date('2022-01-19'),
landed: new Date() landed: new Date('2022-01-19')
}; };
expect(controller.isFormInvalid()).toBeFalsy(); expect(controller.isFormInvalid()).toBeFalsy();
@ -288,7 +288,7 @@ describe('Ticket', () => {
describe('onStepChange()', () => { describe('onStepChange()', () => {
it('should call onStepChange method and return a NO_AGENCY_AVAILABLE signal error', async() => { it('should call onStepChange method and return a NO_AGENCY_AVAILABLE signal error', async() => {
let landed = new Date(); let landed = new Date('2022-01-19');
landed.setHours(0, 0, 0, 0); landed.setHours(0, 0, 0, 0);
controller._ticket = { controller._ticket = {
@ -299,7 +299,7 @@ describe('Ticket', () => {
agencyModeFk: 1, agencyModeFk: 1,
companyFk: 442, companyFk: 442,
warehouseFk: 1, warehouseFk: 1,
shipped: new Date(), shipped: new Date('2022-01-19'),
landed: landed landed: landed
}; };
@ -314,8 +314,8 @@ describe('Ticket', () => {
describe('getLanded()', () => { describe('getLanded()', () => {
it('should return an available landed date', async() => { it('should return an available landed date', async() => {
const shipped = new Date(); const shipped = new Date('2022-01-19');
const expectedResult = {landed: new Date()}; const expectedResult = {landed: new Date('2022-01-19')};
const params = { const params = {
shipped: shipped, shipped: shipped,
addressFk: 121, addressFk: 121,
@ -336,8 +336,8 @@ describe('Ticket', () => {
describe('getShipped()', () => { describe('getShipped()', () => {
it('should return an available shipped date', async() => { it('should return an available shipped date', async() => {
const landed = new Date(); const landed = new Date('2022-01-19');
const expectedResult = {shipped: new Date()}; const expectedResult = {shipped: new Date('2022-01-19')};
const params = { const params = {
landed: landed, landed: landed,
addressFk: 121, addressFk: 121,
@ -358,7 +358,7 @@ describe('Ticket', () => {
describe('zoneWhere() getter', () => { describe('zoneWhere() getter', () => {
it('should return an object containing filter properties', async() => { it('should return an object containing filter properties', async() => {
const shipped = new Date(); const shipped = new Date('2022-01-19');
controller.ticket.shipped = shipped; controller.ticket.shipped = shipped;
const expectedResult = { const expectedResult = {

View File

@ -43,7 +43,7 @@ describe('Ticket Component vnTicketDescriptorMenu', () => {
describe('canRestoreTicket() getter', () => { describe('canRestoreTicket() getter', () => {
it('should return true for a ticket deleted within the last hour', () => { it('should return true for a ticket deleted within the last hour', () => {
controller.ticket.isDeleted = true; controller.ticket.isDeleted = true;
controller.ticket.updated = new Date(); controller.ticket.updated = new Date('2022-01-19');
const result = controller.canRestoreTicket; const result = controller.canRestoreTicket;
@ -51,7 +51,7 @@ describe('Ticket Component vnTicketDescriptorMenu', () => {
}); });
it('should return false for a ticket deleted more than one hour ago', () => { it('should return false for a ticket deleted more than one hour ago', () => {
const pastHour = new Date(); const pastHour = new Date('2022-01-19');
pastHour.setHours(pastHour.getHours() - 2); pastHour.setHours(pastHour.getHours() - 2);
controller.ticket.isDeleted = true; controller.ticket.isDeleted = true;

View File

@ -31,14 +31,14 @@ describe('Component vnTicketIndex', () => {
describe('compareDate()', () => { describe('compareDate()', () => {
it('should return warning when the date is the present', () => { it('should return warning when the date is the present', () => {
let today = new Date(); let today = new Date('2022-01-19');
let result = controller.compareDate(today); let result = controller.compareDate(today);
expect(result).toEqual('warning'); expect(result).toEqual('warning');
}); });
it('should return sucess when the date is in the future', () => { it('should return sucess when the date is in the future', () => {
let futureDate = new Date(); let futureDate = new Date('2022-01-19');
futureDate = futureDate.setDate(futureDate.getDate() + 10); futureDate = futureDate.setDate(futureDate.getDate() + 10);
let result = controller.compareDate(futureDate); let result = controller.compareDate(futureDate);
@ -46,7 +46,7 @@ describe('Component vnTicketIndex', () => {
}); });
it('should return undefined when the date is in the past', () => { it('should return undefined when the date is in the past', () => {
let pastDate = new Date(); let pastDate = new Date('2022-01-19');
pastDate = pastDate.setDate(pastDate.getDate() - 10); pastDate = pastDate.setDate(pastDate.getDate() - 10);
let result = controller.compareDate(pastDate); let result = controller.compareDate(pastDate);

View File

@ -15,9 +15,9 @@ describe('Ticket', () => {
const ticket = { const ticket = {
id: 1, id: 1,
clientFk: 1101, clientFk: 1101,
shipped: new Date(), shipped: new Date('2022-01-19'),
landed: new Date(), landed: new Date('2022-01-19'),
created: new Date(), created: new Date('2022-01-19'),
client: {salesPersonFk: 1}, client: {salesPersonFk: 1},
address: {mobile: 111111111} address: {mobile: 111111111}
}; };

View File

@ -38,7 +38,7 @@ describe('Ticket Component vnTicketSearchPanel', () => {
it('should clear the scope days when setting the from property', () => { it('should clear the scope days when setting the from property', () => {
controller.filter.scopeDays = 1; controller.filter.scopeDays = 1;
controller.from = new Date(); controller.from = new Date('2022-01-19');
expect(controller.filter.scopeDays).toBeNull(); expect(controller.filter.scopeDays).toBeNull();
expect(controller.from).toBeDefined(); expect(controller.from).toBeDefined();
@ -49,7 +49,7 @@ describe('Ticket Component vnTicketSearchPanel', () => {
it('should clear the scope days when setting the to property', () => { it('should clear the scope days when setting the to property', () => {
controller.filter.scopeDays = 1; controller.filter.scopeDays = 1;
controller.to = new Date(); controller.to = new Date('2022-01-19');
expect(controller.filter.scopeDays).toBeNull(); expect(controller.filter.scopeDays).toBeNull();
expect(controller.to).toBeDefined(); expect(controller.to).toBeDefined();
@ -58,8 +58,8 @@ describe('Ticket Component vnTicketSearchPanel', () => {
describe('scopeDays() setter', () => { describe('scopeDays() setter', () => {
it('should clear the date range when setting the scopeDays property', () => { it('should clear the date range when setting the scopeDays property', () => {
controller.filter.from = new Date(); controller.filter.from = new Date('2022-01-19');
controller.filter.to = new Date(); controller.filter.to = new Date('2022-01-19');
controller.scopeDays = 1; controller.scopeDays = 1;

View File

@ -49,7 +49,7 @@ xdescribe('Travel cloneWithEntries()', () => {
it(`should clone the travel and the containing entries`, async() => { it(`should clone the travel and the containing entries`, async() => {
const warehouseThree = 3; const warehouseThree = 3;
const agencyModeOne = 1; const agencyModeOne = 1;
const yesterday = new Date(); const yesterday = new Date('2022-01-19');
yesterday.setDate(yesterday.getDate() - 1); yesterday.setDate(yesterday.getDate() - 1);
travelBefore = await models.Travel.findById(travelId); travelBefore = await models.Travel.findById(travelId);

View File

@ -95,10 +95,10 @@ describe('Travel extraCommunityFilter()', () => {
}); });
it('should return the routes matching "shipped from" and "landed to"', async() => { it('should return the routes matching "shipped from" and "landed to"', async() => {
const from = new Date(); const from = new Date('2022-01-19');
from.setDate(from.getDate() - 2); from.setDate(from.getDate() - 2);
from.setHours(0, 0, 0, 0); from.setHours(0, 0, 0, 0);
const to = new Date(); const to = new Date('2022-01-19');
to.setHours(23, 59, 59, 999); to.setHours(23, 59, 59, 999);
to.setDate(to.getDate() + 7); to.setDate(to.getDate() + 7);
const ctx = { const ctx = {

View File

@ -54,8 +54,8 @@ describe('Travel filter()', () => {
}); });
it('should return the routes matching "shipped from" and "shipped to"', async() => { it('should return the routes matching "shipped from" and "shipped to"', async() => {
const from = new Date(); const from = new Date('2022-01-19');
const to = new Date(); const to = new Date('2022-01-19');
from.setHours(0, 0, 0, 0); from.setHours(0, 0, 0, 0);
to.setHours(23, 59, 59, 999); to.setHours(23, 59, 59, 999);
to.setDate(to.getDate() + 1); to.setDate(to.getDate() + 1);

View File

@ -53,7 +53,7 @@ describe('Travel Component vnTravelCreate', () => {
it(`should do nothing if there's no response data.`, () => { it(`should do nothing if there's no response data.`, () => {
controller.travel = {agencyModeFk: 4}; controller.travel = {agencyModeFk: 4};
const tomorrow = new Date(); const tomorrow = new Date('2022-01-19');
const query = `travels/getAverageDays?agencyModeFk=${controller.travel.agencyModeFk}`; const query = `travels/getAverageDays?agencyModeFk=${controller.travel.agencyModeFk}`;
$httpBackend.expectGET(query).respond(undefined); $httpBackend.expectGET(query).respond(undefined);
@ -67,7 +67,7 @@ describe('Travel Component vnTravelCreate', () => {
it(`should fill the fields when it's selected a date and agency.`, () => { it(`should fill the fields when it's selected a date and agency.`, () => {
controller.travel = {agencyModeFk: 1}; controller.travel = {agencyModeFk: 1};
const tomorrow = new Date(); const tomorrow = new Date('2022-01-19');
tomorrow.setDate(tomorrow.getDate() + 9); tomorrow.setDate(tomorrow.getDate() + 9);
const expectedResponse = { const expectedResponse = {
id: 8, id: 8,

View File

@ -16,7 +16,7 @@ describe('Travel Component vnTravelExtraCommunity', () => {
describe('hasDateRange()', () => { describe('hasDateRange()', () => {
it('should return truthy when shippedFrom or landedTo are set as userParams', () => { it('should return truthy when shippedFrom or landedTo are set as userParams', () => {
const now = new Date(); const now = new Date('2022-01-19');
controller.$.model.userParams = {shippedFrom: now, landedTo: now}; controller.$.model.userParams = {shippedFrom: now, landedTo: now};
const result = controller.hasDateRange; const result = controller.hasDateRange;

View File

@ -50,7 +50,7 @@ describe('Travel Component vnTravelIndex', () => {
describe('compareDate()', () => { describe('compareDate()', () => {
it('should return warning if the date passed to compareDate() is todays', () => { it('should return warning if the date passed to compareDate() is todays', () => {
const today = new Date(); const today = new Date('2022-01-19');
const result = controller.compareDate(today); const result = controller.compareDate(today);
@ -58,7 +58,7 @@ describe('Travel Component vnTravelIndex', () => {
}); });
it('should return success if the date passed to compareDate() is in the future', () => { it('should return success if the date passed to compareDate() is in the future', () => {
const tomorrow = new Date(); const tomorrow = new Date('2022-01-19');
tomorrow.setDate(tomorrow.getDate() + 1); tomorrow.setDate(tomorrow.getDate() + 1);
const result = controller.compareDate(tomorrow); const result = controller.compareDate(tomorrow);
@ -67,7 +67,7 @@ describe('Travel Component vnTravelIndex', () => {
}); });
it('should return undefined if the date passed to compareDate() is in the past', () => { it('should return undefined if the date passed to compareDate() is in the past', () => {
const yesterday = new Date(); const yesterday = new Date('2022-01-19');
yesterday.setDate(yesterday.getDate() - 1); yesterday.setDate(yesterday.getDate() - 1);
const result = controller.compareDate(yesterday); const result = controller.compareDate(yesterday);

View File

@ -15,7 +15,7 @@ describe('Travel Component vnTravel', () => {
let params = controller.fetchParams({ let params = controller.fetchParams({
scopeDays: 2 scopeDays: 2
}); });
const shippedFrom = new Date(); const shippedFrom = new Date('2022-01-19');
shippedFrom.setHours(0, 0, 0, 0); shippedFrom.setHours(0, 0, 0, 0);
const shippedTo = new Date(shippedFrom.getTime()); const shippedTo = new Date(shippedFrom.getTime());
shippedTo.setDate(shippedTo.getDate() + params.scopeDays); shippedTo.setDate(shippedTo.getDate() + params.scopeDays);

View File

@ -15,7 +15,7 @@ describe('Travel Component vnTravelSearchPanel', () => {
it('should clear the scope days when setting the from property', () => { it('should clear the scope days when setting the from property', () => {
controller.filter.scopeDays = 1; controller.filter.scopeDays = 1;
controller.shippedFrom = new Date(); controller.shippedFrom = new Date('2022-01-19');
expect(controller.filter.scopeDays).toBeNull(); expect(controller.filter.scopeDays).toBeNull();
expect(controller.shippedFrom).toBeDefined(); expect(controller.shippedFrom).toBeDefined();
@ -26,7 +26,7 @@ describe('Travel Component vnTravelSearchPanel', () => {
it('should clear the scope days when setting the to property', () => { it('should clear the scope days when setting the to property', () => {
controller.filter.scopeDays = 1; controller.filter.scopeDays = 1;
controller.shippedTo = new Date(); controller.shippedTo = new Date('2022-01-19');
expect(controller.filter.scopeDays).toBeNull(); expect(controller.filter.scopeDays).toBeNull();
expect(controller.shippedTo).toBeDefined(); expect(controller.shippedTo).toBeDefined();
@ -35,8 +35,8 @@ describe('Travel Component vnTravelSearchPanel', () => {
describe('scopeDays() setter', () => { describe('scopeDays() setter', () => {
it('should clear the date range when setting the scopeDays property', () => { it('should clear the date range when setting the scopeDays property', () => {
controller.filter.shippedFrom = new Date(); controller.filter.shippedFrom = new Date('2022-01-19');
controller.filter.shippedTo = new Date(); controller.filter.shippedTo = new Date('2022-01-19');
controller.scopeDays = 1; controller.scopeDays = 1;

View File

@ -6,7 +6,7 @@ describe('Worker absences()', () => {
const workerId = 1106; const workerId = 1106;
const businessId = 1106; const businessId = 1106;
const now = new Date(); const now = new Date('2022-01-19');
const year = now.getFullYear(); const year = now.getFullYear();
const [absences] = await app.models.Calendar.absences(ctx, workerId, businessId, year); const [absences] = await app.models.Calendar.absences(ctx, workerId, businessId, year);
@ -22,7 +22,7 @@ describe('Worker absences()', () => {
const businessId = 1106; const businessId = 1106;
const ctx = {req: {accessToken: {userId: 9}}}; const ctx = {req: {accessToken: {userId: 9}}};
const now = new Date(); const now = new Date('2022-01-19');
const year = now.getFullYear(); const year = now.getFullYear();
const tx = await app.models.Calendar.beginTransaction({}); const tx = await app.models.Calendar.beginTransaction({});
@ -55,15 +55,15 @@ describe('Worker absences()', () => {
const workerId = 1106; const workerId = 1106;
const userId = 1106; const userId = 1106;
const today = new Date(); const today = new Date('2022-01-19');
// getting how many days in a year // getting how many days in a year
const yearStart = new Date(); const yearStart = new Date('2022-01-19');
yearStart.setHours(0, 0, 0, 0); yearStart.setHours(0, 0, 0, 0);
yearStart.setMonth(0); yearStart.setMonth(0);
yearStart.setDate(1); yearStart.setDate(1);
const yearEnd = new Date(); const yearEnd = new Date('2022-01-19');
const currentYear = yearEnd.getFullYear(); const currentYear = yearEnd.getFullYear();
yearEnd.setFullYear(currentYear + 1); yearEnd.setFullYear(currentYear + 1);
yearEnd.setHours(0, 0, 0, 0); yearEnd.setHours(0, 0, 0, 0);
@ -92,7 +92,7 @@ describe('Worker absences()', () => {
// normal test begins // normal test begins
const contract = await app.models.WorkerLabour.findById(businessId, null, options); const contract = await app.models.WorkerLabour.findById(businessId, null, options);
const startingContract = new Date(); const startingContract = new Date('2022-01-19');
startingContract.setHours(0, 0, 0, 0); startingContract.setHours(0, 0, 0, 0);
startingContract.setMonth(today.getMonth()); startingContract.setMonth(today.getMonth());
startingContract.setDate(1); startingContract.setDate(1);

View File

@ -3,9 +3,9 @@ const app = require('vn-loopback/server/server');
describe('workerTimeControl filter()', () => { describe('workerTimeControl filter()', () => {
it('should return 1 result filtering by id', async() => { it('should return 1 result filtering by id', async() => {
let ctx = {req: {accessToken: {userId: 1106}}, args: {workerFk: 1106}}; let ctx = {req: {accessToken: {userId: 1106}}, args: {workerFk: 1106}};
const firstHour = new Date(); const firstHour = new Date('2022-01-19');
firstHour.setHours(7, 0, 0, 0); firstHour.setHours(7, 0, 0, 0);
const lastHour = new Date(); const lastHour = new Date('2022-01-19');
lastHour.setDate(lastHour.getDate() + 1); lastHour.setDate(lastHour.getDate() + 1);
lastHour.setHours(15, 0, 0, 0); lastHour.setHours(15, 0, 0, 0);
@ -21,9 +21,9 @@ describe('workerTimeControl filter()', () => {
it('should return a privilege error for a non subordinate worker', async() => { it('should return a privilege error for a non subordinate worker', async() => {
let ctx = {req: {accessToken: {userId: 1107}}, args: {workerFk: 1106}}; let ctx = {req: {accessToken: {userId: 1107}}, args: {workerFk: 1106}};
const firstHour = new Date(); const firstHour = new Date('2022-01-19');
firstHour.setHours(7, 0, 0, 0); firstHour.setHours(7, 0, 0, 0);
const lastHour = new Date(); const lastHour = new Date('2022-01-19');
lastHour.setDate(lastHour.getDate() + 1); lastHour.setDate(lastHour.getDate() + 1);
lastHour.setHours(15, 0, 0, 0); lastHour.setHours(15, 0, 0, 0);

View File

@ -26,7 +26,7 @@ describe('workerTimeControl add/delete timeEntry()', () => {
let error; let error;
try { try {
ctx.args = {timed: new Date(), direction: 'in'}; ctx.args = {timed: new Date('2022-01-19'), direction: 'in'};
await models.WorkerTimeControl.addTimeEntry(ctx, workerId); await models.WorkerTimeControl.addTimeEntry(ctx, workerId);
} catch (e) { } catch (e) {
error = e; error = e;
@ -43,7 +43,7 @@ describe('workerTimeControl add/delete timeEntry()', () => {
let error; let error;
try { try {
ctx.args = {timed: new Date(), direction: 'in'}; ctx.args = {timed: new Date('2022-01-19'), direction: 'in'};
await models.WorkerTimeControl.addTimeEntry(ctx, workerId); await models.WorkerTimeControl.addTimeEntry(ctx, workerId);
} catch (e) { } catch (e) {
error = e; error = e;
@ -62,7 +62,7 @@ describe('workerTimeControl add/delete timeEntry()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const todayAtSix = new Date(); const todayAtSix = new Date('2022-01-19');
todayAtSix.setHours(18, 30, 0, 0); todayAtSix.setHours(18, 30, 0, 0);
ctx.args = {timed: todayAtSix, direction: 'in'}; ctx.args = {timed: todayAtSix, direction: 'in'};
@ -103,7 +103,7 @@ describe('workerTimeControl add/delete timeEntry()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const todayAtSeven = new Date(); const todayAtSeven = new Date('2022-01-19');
todayAtSeven.setHours(19, 30, 0, 0); todayAtSeven.setHours(19, 30, 0, 0);
ctx.args = {timed: todayAtSeven, direction: 'in'}; ctx.args = {timed: todayAtSeven, direction: 'in'};
@ -131,7 +131,7 @@ describe('workerTimeControl add/delete timeEntry()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const todayAtFive = new Date(); const todayAtFive = new Date('2022-01-19');
todayAtFive.setHours(17, 30, 0, 0); todayAtFive.setHours(17, 30, 0, 0);
ctx.args = {timed: todayAtFive, direction: 'in'}; ctx.args = {timed: todayAtFive, direction: 'in'};
@ -159,7 +159,7 @@ describe('workerTimeControl add/delete timeEntry()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const todayAtFive = new Date(); const todayAtFive = new Date('2022-01-19');
todayAtFive.setHours(17, 30, 0, 0); todayAtFive.setHours(17, 30, 0, 0);
ctx.args = {timed: todayAtFive, direction: 'in'}; ctx.args = {timed: todayAtFive, direction: 'in'};
@ -187,7 +187,7 @@ describe('workerTimeControl add/delete timeEntry()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const todayAtFive = new Date(); const todayAtFive = new Date('2022-01-19');
todayAtFive.setHours(17, 30, 0, 0); todayAtFive.setHours(17, 30, 0, 0);
ctx.args = {timed: todayAtFive, direction: 'in'}; ctx.args = {timed: todayAtFive, direction: 'in'};

View File

@ -10,7 +10,7 @@ describe('Worker createAbsence()', () => {
args: { args: {
businessFk: 18, businessFk: 18,
absenceTypeId: 1, absenceTypeId: 1,
dated: new Date() dated: new Date('2022-01-19')
} }
}; };
@ -45,7 +45,7 @@ describe('Worker createAbsence()', () => {
args: { args: {
businessFk: 18, businessFk: 18,
absenceTypeId: 1, absenceTypeId: 1,
dated: new Date() dated: new Date('2022-01-19')
} }
}; };
ctx.req.__ = value => { ctx.req.__ = value => {
@ -82,7 +82,7 @@ describe('Worker createAbsence()', () => {
id: 1, id: 1,
businessFk: 1, businessFk: 1,
absenceTypeId: 6, absenceTypeId: 6,
dated: new Date() dated: new Date('2022-01-19')
} }
}; };
const workerId = 1; const workerId = 1;
@ -111,7 +111,7 @@ describe('Worker createAbsence()', () => {
id: 1106, id: 1106,
businessFk: 1106, businessFk: 1106,
absenceTypeId: 1, absenceTypeId: 1,
dated: new Date() dated: new Date('2022-01-19')
} }
}; };
const workerId = 1106; const workerId = 1106;

View File

@ -28,7 +28,7 @@ describe('Worker deleteAbsence()', () => {
const createdAbsence = await app.models.Calendar.create({ const createdAbsence = await app.models.Calendar.create({
businessFk: businessId, businessFk: businessId,
dayOffTypeFk: 1, dayOffTypeFk: 1,
dated: new Date() dated: new Date('2022-01-19')
}, options); }, options);
ctx.args = {absenceId: createdAbsence.id}; ctx.args = {absenceId: createdAbsence.id};
@ -59,7 +59,7 @@ describe('Worker deleteAbsence()', () => {
const createdAbsence = await app.models.Calendar.create({ const createdAbsence = await app.models.Calendar.create({
businessFk: businessId, businessFk: businessId,
dayOffTypeFk: 1, dayOffTypeFk: 1,
dated: new Date() dated: new Date('2022-01-19')
}, options); }, options);
ctx.args = {absenceId: createdAbsence.id}; ctx.args = {absenceId: createdAbsence.id};

View File

@ -3,10 +3,10 @@ const models = require('vn-loopback/server/server').models;
describe('Worker getWorkedHours()', () => { describe('Worker getWorkedHours()', () => {
it(`should return the expected hours and the worked hours of a given date`, async() => { it(`should return the expected hours and the worked hours of a given date`, async() => {
const workerID = 1106; const workerID = 1106;
const started = new Date(); const started = new Date('2022-01-19');
started.setHours(0, 0, 0, 0); started.setHours(0, 0, 0, 0);
const ended = new Date(); const ended = new Date('2022-01-19');
ended.setHours(23, 59, 59, 999); ended.setHours(23, 59, 59, 999);
const [result] = await models.Worker.getWorkedHours(workerID, started, ended); const [result] = await models.Worker.getWorkedHours(workerID, started, ended);

View File

@ -17,7 +17,7 @@ describe('Worker holidays()', () => {
}); });
it('should now get the absence calendar for a full year contract', async() => { it('should now get the absence calendar for a full year contract', async() => {
const now = new Date(); const now = new Date('2022-01-19');
const year = now.getFullYear(); const year = now.getFullYear();
ctx.args = {businessFk: businessId, year: year}; ctx.args = {businessFk: businessId, year: year};

View File

@ -21,7 +21,7 @@ describe('Worker updateAbsence()', () => {
createdAbsence = await app.models.Calendar.create({ createdAbsence = await app.models.Calendar.create({
businessFk: businessId, businessFk: businessId,
dayOffTypeFk: 1, dayOffTypeFk: 1,
dated: new Date() dated: new Date('2022-01-19')
}); });
}); });

View File

@ -6,7 +6,7 @@ describe('Worker', () => {
let $httpParamSerializer; let $httpParamSerializer;
let $scope; let $scope;
let controller; let controller;
let year = new Date().getFullYear(); let year = new Date('2022-01-19').getFullYear();
beforeEach(ngModule('worker')); beforeEach(ngModule('worker'));
@ -67,7 +67,7 @@ describe('Worker', () => {
controller.getIsSubordinate = jest.fn(); controller.getIsSubordinate = jest.fn();
controller.getActiveContract = jest.fn(); controller.getActiveContract = jest.fn();
let today = new Date(); let today = new Date('2022-01-19');
let tomorrow = new Date(today.getTime()); let tomorrow = new Date(today.getTime());
tomorrow.setDate(tomorrow.getDate() + 1); tomorrow.setDate(tomorrow.getDate() + 1);
@ -105,7 +105,7 @@ describe('Worker', () => {
describe('getContractHolidays()', () => { describe('getContractHolidays()', () => {
it(`should return the worker holidays amount and then set the contractHolidays property`, () => { it(`should return the worker holidays amount and then set the contractHolidays property`, () => {
const today = new Date(); const today = new Date('2022-01-19');
const year = today.getFullYear(); const year = today.getFullYear();
const serializedParams = $httpParamSerializer({year}); const serializedParams = $httpParamSerializer({year});
@ -119,7 +119,7 @@ describe('Worker', () => {
describe('formatDay()', () => { describe('formatDay()', () => {
it(`should set the day element style`, () => { it(`should set the day element style`, () => {
const today = new Date(); const today = new Date('2022-01-19');
controller.events[today.getTime()] = { controller.events[today.getTime()] = {
name: 'Holiday', name: 'Holiday',
@ -170,7 +170,7 @@ describe('Worker', () => {
it(`should call to the create() method`, () => { it(`should call to the create() method`, () => {
jest.spyOn(controller, 'create').mockReturnThis(); jest.spyOn(controller, 'create').mockReturnThis();
const selectedDay = new Date(); const selectedDay = new Date('2022-01-19');
const $event = { const $event = {
target: { target: {
closest: () => { closest: () => {
@ -188,7 +188,7 @@ describe('Worker', () => {
it(`should call to the delete() method`, () => { it(`should call to the delete() method`, () => {
jest.spyOn(controller, 'delete').mockReturnThis(); jest.spyOn(controller, 'delete').mockReturnThis();
const selectedDay = new Date(); const selectedDay = new Date('2022-01-19');
const expectedEvent = { const expectedEvent = {
dated: selectedDay, dated: selectedDay,
type: 'holiday', type: 'holiday',
@ -212,7 +212,7 @@ describe('Worker', () => {
it(`should call to the edit() method`, () => { it(`should call to the edit() method`, () => {
jest.spyOn(controller, 'edit').mockReturnThis(); jest.spyOn(controller, 'edit').mockReturnThis();
const selectedDay = new Date(); const selectedDay = new Date('2022-01-19');
const expectedEvent = { const expectedEvent = {
dated: selectedDay, dated: selectedDay,
type: 'leaveOfAbsence', type: 'leaveOfAbsence',
@ -238,7 +238,7 @@ describe('Worker', () => {
it(`should make a HTTP POST query and then call to the repaintCanceller() method`, () => { it(`should make a HTTP POST query and then call to the repaintCanceller() method`, () => {
jest.spyOn(controller, 'repaintCanceller').mockReturnThis(); jest.spyOn(controller, 'repaintCanceller').mockReturnThis();
const dated = new Date(); const dated = new Date('2022-01-19');
const calendarElement = {}; const calendarElement = {};
const expectedResponse = {id: 10}; const expectedResponse = {id: 10};
@ -287,7 +287,7 @@ describe('Worker', () => {
const expectedParams = {absenceId: 10}; const expectedParams = {absenceId: 10};
const calendarElement = {}; const calendarElement = {};
const selectedDay = new Date(); const selectedDay = new Date('2022-01-19');
const expectedEvent = { const expectedEvent = {
dated: selectedDay, dated: selectedDay,
type: 'leaveOfAbsence', type: 'leaveOfAbsence',

View File

@ -18,7 +18,7 @@ describe('Component vnWorkerTimeControl', () => {
describe('date() setter', () => { describe('date() setter', () => {
it(`should set the weekDays, the date in the controller and call fetchHours`, () => { it(`should set the weekDays, the date in the controller and call fetchHours`, () => {
let today = new Date(); let today = new Date('2022-01-19');
jest.spyOn(controller, 'fetchHours').mockReturnThis(); jest.spyOn(controller, 'fetchHours').mockReturnThis();
controller.date = today; controller.date = today;
@ -33,7 +33,7 @@ describe('Component vnWorkerTimeControl', () => {
describe('hours() setter', () => { describe('hours() setter', () => {
it(`should set hours data at it's corresponding week day`, () => { it(`should set hours data at it's corresponding week day`, () => {
let today = new Date(); let today = new Date('2022-01-19');
jest.spyOn(controller, 'fetchHours').mockReturnThis(); jest.spyOn(controller, 'fetchHours').mockReturnThis();
controller.date = today; controller.date = today;
@ -64,7 +64,7 @@ describe('Component vnWorkerTimeControl', () => {
describe('getWorkedHours() ', () => { describe('getWorkedHours() ', () => {
it('should set the weekdays expected and worked hours plus the total worked hours', () => { it('should set the weekdays expected and worked hours plus the total worked hours', () => {
let today = new Date(); let today = new Date('2022-01-19');
jest.spyOn(controller, 'fetchHours').mockReturnThis(); jest.spyOn(controller, 'fetchHours').mockReturnThis();
controller.date = today; controller.date = today;
@ -117,7 +117,7 @@ describe('Component vnWorkerTimeControl', () => {
describe('save() ', () => { describe('save() ', () => {
it(`should make a query an then call to the fetchHours() method`, () => { it(`should make a query an then call to the fetchHours() method`, () => {
controller.fetchHours = jest.fn(); controller.fetchHours = jest.fn();
controller.selectedRow = {id: 1, timed: new Date(), direction: 'in'}; controller.selectedRow = {id: 1, timed: new Date('2022-01-19'), direction: 'in'};
controller.$.editEntry = { controller.$.editEntry = {
hide: () => {} hide: () => {}
}; };

View File

@ -1,7 +1,7 @@
const app = require('vn-loopback/server/server'); const app = require('vn-loopback/server/server');
describe('Agency getAgenciesWithWarehouse()', () => { describe('Agency getAgenciesWithWarehouse()', () => {
const today = new Date(); const today = new Date('2022-01-19');
it('should return the agencies that can handle the given delivery request', async() => { it('should return the agencies that can handle the given delivery request', async() => {
const tx = await app.models.Zone.beginTransaction({}); const tx = await app.models.Zone.beginTransaction({});

View File

@ -3,7 +3,7 @@ const app = require('vn-loopback/server/server');
describe('agency getLanded()', () => { describe('agency getLanded()', () => {
it('should return a landing date', async() => { it('should return a landing date', async() => {
const ctx = {req: {accessToken: {userId: 1}}}; const ctx = {req: {accessToken: {userId: 1}}};
const shipped = new Date(); const shipped = new Date('2022-01-19');
shipped.setDate(shipped.getDate() + 1); shipped.setDate(shipped.getDate() + 1);
const addressFk = 121; const addressFk = 121;
const agencyModeFk = 7; const agencyModeFk = 7;

View File

@ -2,7 +2,7 @@ const app = require('vn-loopback/server/server');
describe('agency getShipped()', () => { describe('agency getShipped()', () => {
it('should return a shipment date', async() => { it('should return a shipment date', async() => {
const landed = new Date(); const landed = new Date('2022-01-19');
landed.setDate(landed.getDate() + 1); landed.setDate(landed.getDate() + 1);
const addressFk = 121; const addressFk = 121;
const agencyModeFk = 7; const agencyModeFk = 7;
@ -25,7 +25,7 @@ describe('agency getShipped()', () => {
}); });
it('should not return a shipment date', async() => { it('should not return a shipment date', async() => {
const newDate = new Date(); const newDate = new Date('2022-01-19');
newDate.setMonth(newDate.getMonth() - 1); newDate.setMonth(newDate.getMonth() - 1);
const landed = newDate; const landed = newDate;
const addressFk = 121; const addressFk = 121;

View File

@ -1,7 +1,7 @@
const app = require('vn-loopback/server/server'); const app = require('vn-loopback/server/server');
describe('Agency landsThatDay()', () => { describe('Agency landsThatDay()', () => {
const today = new Date(); const today = new Date('2022-01-19');
it('should return a list of agencies that can land a shipment on a day for an address', async() => { it('should return a list of agencies that can land a shipment on a day for an address', async() => {
const tx = await app.models.Agency.beginTransaction({}); const tx = await app.models.Agency.beginTransaction({});

View File

@ -6,7 +6,7 @@ describe('zone getZoneClosing()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const date = new Date(); const date = new Date('2022-01-19');
const today = date.toISOString().split('T')[0]; const today = date.toISOString().split('T')[0];
const result = await models.Zone.getZoneClosing([1, 2, 3], today, options); const result = await models.Zone.getZoneClosing([1, 2, 3], today, options);

View File

@ -50,7 +50,7 @@ describe('zone includingExpired()', () => {
it('should return an array containing available zones', async() => { it('should return an array containing available zones', async() => {
const ctx = {req: {accessToken: {userId: 1}}}; const ctx = {req: {accessToken: {userId: 1}}};
const where = { const where = {
shipped: new Date(), shipped: new Date('2022-01-19'),
addressFk: addressId, addressFk: addressId,
agencyModeFk: inhousePickupId, agencyModeFk: inhousePickupId,
warehouseFk: warehouseId warehouseFk: warehouseId

View File

@ -21,7 +21,7 @@ describe('component vnZoneCalendar', () => {
it('should set the month property and then call the refreshEvents() method', () => { it('should set the month property and then call the refreshEvents() method', () => {
jest.spyOn(controller, 'refreshEvents').mockReturnThis(); jest.spyOn(controller, 'refreshEvents').mockReturnThis();
controller.date = new Date(); controller.date = new Date('2022-01-19');
expect(controller.refreshEvents).toHaveBeenCalledWith(); expect(controller.refreshEvents).toHaveBeenCalledWith();
expect(controller.months.length).toEqual(4); expect(controller.months.length).toEqual(4);
@ -30,7 +30,7 @@ describe('component vnZoneCalendar', () => {
describe('step()', () => { describe('step()', () => {
it('should set the date month to 4 months backwards', () => { it('should set the date month to 4 months backwards', () => {
const now = new Date(); const now = new Date('2022-01-19');
now.setDate(15); now.setDate(15);
now.setMonth(now.getMonth() - 4); now.setMonth(now.getMonth() - 4);
@ -43,7 +43,7 @@ describe('component vnZoneCalendar', () => {
}); });
it('should set the date month to 4 months forwards', () => { it('should set the date month to 4 months forwards', () => {
const now = new Date(); const now = new Date('2022-01-19');
now.setDate(15); now.setDate(15);
now.setMonth(now.getMonth() + 4); now.setMonth(now.getMonth() + 4);
@ -62,10 +62,10 @@ describe('component vnZoneCalendar', () => {
controller.data = { controller.data = {
exclusions: [{ exclusions: [{
dated: new Date() dated: new Date('2022-01-19')
}], }],
events: [{ events: [{
dated: new Date() dated: new Date('2022-01-19')
}] }]
}; };
@ -80,9 +80,9 @@ describe('component vnZoneCalendar', () => {
describe('refreshEvents()', () => { describe('refreshEvents()', () => {
it('should fill the days property with the events.', () => { it('should fill the days property with the events.', () => {
controller.data = []; controller.data = [];
controller.firstDay = new Date(); controller.firstDay = new Date('2022-01-19');
const lastDay = new Date(); const lastDay = new Date('2022-01-19');
lastDay.setDate(lastDay.getDate() + 10); lastDay.setDate(lastDay.getDate() + 10);
controller.lastDay = lastDay; controller.lastDay = lastDay;
@ -109,7 +109,7 @@ describe('component vnZoneCalendar', () => {
jest.spyOn(controller, 'emit'); jest.spyOn(controller, 'emit');
const $event = {}; const $event = {};
const $days = [new Date()]; const $days = [new Date('2022-01-19')];
const $type = 'day'; const $type = 'day';
const $weekday = 1; const $weekday = 1;
@ -130,7 +130,7 @@ describe('component vnZoneCalendar', () => {
describe('hasEvents()', () => { describe('hasEvents()', () => {
it('should return true for an existing event on a date', () => { it('should return true for an existing event on a date', () => {
const dated = new Date(); const dated = new Date('2022-01-19');
controller.days[dated.getTime()] = true; controller.days[dated.getTime()] = true;
@ -142,7 +142,7 @@ describe('component vnZoneCalendar', () => {
describe('getClass()', () => { describe('getClass()', () => {
it('should return the className "excluded" for an excluded date', () => { it('should return the className "excluded" for an excluded date', () => {
const dated = new Date(); const dated = new Date('2022-01-19');
controller.exclusions = []; controller.exclusions = [];
controller.exclusions[dated.getTime()] = true; controller.exclusions[dated.getTime()] = true;

View File

@ -103,7 +103,7 @@ describe('Zone Component vnZoneDeliveryDays', () => {
const target = document.createElement('div'); const target = document.createElement('div');
target.dispatchEvent(event); target.dispatchEvent(event);
const day = new Date(); const day = new Date('2022-01-19');
const events = [ const events = [
{zoneFk: 1}, {zoneFk: 1},
{zoneFk: 2}, {zoneFk: 2},

View File

@ -65,7 +65,7 @@ describe('component vnZoneEvents', () => {
it('should call the create() method', () => { it('should call the create() method', () => {
jest.spyOn(controller, 'create').mockReturnThis(); jest.spyOn(controller, 'create').mockReturnThis();
const weekday = {dated: new Date()}; const weekday = {dated: new Date('2022-01-19')};
const days = [weekday]; const days = [weekday];
const type = 'EventType'; const type = 'EventType';
const events = []; const events = [];
@ -94,7 +94,7 @@ describe('component vnZoneEvents', () => {
jest.spyOn(controller, 'exclusionCreate').mockReturnThis(); jest.spyOn(controller, 'exclusionCreate').mockReturnThis();
const weekday = {}; const weekday = {};
const days = [{dated: new Date()}]; const days = [{dated: new Date('2022-01-19')}];
const type = 'EventType'; const type = 'EventType';
const events = []; const events = [];
const exclusions = []; const exclusions = [];
@ -110,7 +110,7 @@ describe('component vnZoneEvents', () => {
controller.$.dialog = {show: jest.fn()}; controller.$.dialog = {show: jest.fn()};
const type = 'weekday'; const type = 'weekday';
const days = [new Date()]; const days = [new Date('2022-01-19')];
const weekday = 1; const weekday = 1;
controller.create(type, days, weekday); controller.create(type, days, weekday);
@ -127,7 +127,7 @@ describe('component vnZoneEvents', () => {
controller.$.dialog = {show: jest.fn()}; controller.$.dialog = {show: jest.fn()};
const type = 'nonListedType'; const type = 'nonListedType';
const days = [new Date()]; const days = [new Date('2022-01-19')];
const weekday = 1; const weekday = 1;
controller.create(type, days, weekday); controller.create(type, days, weekday);
@ -197,7 +197,7 @@ describe('component vnZoneEvents', () => {
it('shoud make an HTTP POST query and then call the refresh() method', () => { it('shoud make an HTTP POST query and then call the refresh() method', () => {
jest.spyOn(controller, 'refresh').mockReturnThis(); jest.spyOn(controller, 'refresh').mockReturnThis();
const dates = [new Date()]; const dates = [new Date('2022-01-19')];
$httpBackend.expect('POST', `Zones/1/exclusions`).respond({id: 1}); $httpBackend.expect('POST', `Zones/1/exclusions`).respond({id: 1});
controller.exclusionCreate(dates); controller.exclusionCreate(dates);
$httpBackend.flush(); $httpBackend.flush();