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()', () => {
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 randomIndex = Math.floor(Math.random() * result.length);
const campaignDated = result[randomIndex].dated;
@ -12,7 +12,7 @@ describe('campaign latest()', () => {
});
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 result = await app.models.Campaign.latest({
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() => {
const response = await app.models.Campaign.upcoming();
const campaignDated = response.dated;
const now = new Date();
const now = new Date('2022-01-19');
expect(campaignDated).toEqual(jasmine.any(Date));
expect(campaignDated).toBeLessThanOrEqual(now);

View File

@ -1,7 +1,7 @@
const models = require('vn-loopback/server/server').models;
describe('Chat sendCheckingPresence()', () => {
const today = new Date();
const today = new Date('2022-01-19');
today.setHours(6, 0);
const ctx = {req: {accessToken: {userId: 1}}};
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 \
${SCHEMAS[@]} \
${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' \
> dump/structure.sql

View File

@ -2,7 +2,7 @@ const app = require('vn-loopback/server/server');
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
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() => {
let stmts = [];
let stmt;

View File

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

View File

@ -2,7 +2,7 @@ const app = require('vn-loopback/server/server');
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
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() => {
let stmts = [];
let stmt;

View File

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

View File

@ -3,9 +3,9 @@ const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
describe('timeBusiness_calculateByUser()', () => {
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);
let end = new Date();
let end = new Date('2022-01-19');
end.setHours(0, 0, 0, 0);
let stmts = [];

View File

@ -3,11 +3,11 @@ const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
describe('timeControl_calculateByUser()', () => {
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.setDate(start.getDate() - 1);
let end = new Date();
let end = new Date('2022-01-19');
end.setHours(0, 0, 0, 0);
end.setDate(end.getDate() + 1);
@ -48,14 +48,14 @@ describe('timeControl_calculateByUser()', () => {
});
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();
if (daysSinceSunday === 0) // this means today is sunday but you need the previous sunday :)
daysSinceSunday = 7;
lastSunday.setHours(23, 0, 0, 0);
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)
monday.setHours(7, 0, 0, 0);
monday.setDate(monday.getDate() - daysSinceMonday);

View File

@ -4,7 +4,7 @@ import getBrowser from '../../helpers/puppeteer';
describe('Client credit insurance path', () => {
let browser;
let page;
let previousMonth = new Date();
let previousMonth = new Date('2022-01-19');
previousMonth.setMonth(previousMonth.getMonth() - 1);
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() => {
const date = new Date();
const date = new Date('2022-01-19');
const lastYear = (date.getFullYear() - 1).toString();
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() => {
const now = new Date();
const now = new Date('2022-01-19');
await page.autocompleteSearch(selectors.itemFixedPrice.fourthWarehouse, 'Warehouse one');
await page.write(selectors.itemFixedPrice.fourthPPU, '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() => {
const newAgency = 'Silla247';
const newDate = new Date();
const newDate = new Date('2022-01-19');
newDate.setDate(newDate.getDate() - 1);
await page.accessToSearchResult('14');
@ -128,7 +128,7 @@ describe('Ticket Edit basic data path', () => {
});
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';
await page.accessToSearchResult('14');

View File

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

View File

@ -18,7 +18,7 @@ describe('Route basic Data path', () => {
});
it('should edit the route basic data', async() => {
const nextMonth = new Date();
const nextMonth = new Date('2022-01-19');
nextMonth.setMonth(nextMonth.getMonth() + 1);
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() => {
const now = new Date();
const now = new Date('2022-01-19');
await page.pickDate(selectors.invoiceInBasicData.issued, now);
await page.pickDate(selectors.invoiceInBasicData.operated, now);
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() => {
let today = new Date();
let today = new Date('2022-01-19');
let day = today.getDate();
if (day < 10) day = `0${day}`;

View File

@ -4,7 +4,7 @@ import getBrowser from '../../helpers/puppeteer';
describe('Travel create path', () => {
let browser;
let page;
const date = new Date();
const date = new Date('2022-01-19');
const day = 15;
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() => {
const lastMonth = new Date();
const lastMonth = new Date('2022-01-19');
lastMonth.setMonth(lastMonth.getMonth() - 1);
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() => {
const nextMonth = new Date();
const nextMonth = new Date('2022-01-19');
nextMonth.setMonth(nextMonth.getMonth() + 1);
await page.pickDate(selectors.travelBasicData.deliveryDate, nextMonth);
await page.waitToClick(selectors.travelBasicData.save);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -49,14 +49,14 @@ describe('client defaulter', () => {
describe('chipColor()', () => {
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);
expect(result).toEqual(undefined);
});
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);
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', () => {
let pastDate = new Date();
let pastDate = new Date('2022-01-19');
pastDate = pastDate.setDate(pastDate.getDate() - 21);
let result = controller.chipColor(pastDate);

View File

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

View File

@ -76,14 +76,14 @@ describe('Client', () => {
describe('chipColor()', () => {
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);
expect(result).toEqual('warning');
});
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);
let result = controller.chipColor(futureDate);
@ -91,7 +91,7 @@ describe('Client', () => {
});
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);
let result = controller.chipColor(pastDate);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -8,7 +8,7 @@ describe('item getVisibleAvailable()', () => {
try {
const itemFk = 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);
@ -29,7 +29,7 @@ describe('item getVisibleAvailable()', () => {
try {
const itemFk = 1;
const warehouseFk = 1;
const dated = new Date();
const dated = new Date('2022-01-19');
dated.setDate(dated.getDate() - 1);
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', () => {
const now = new Date();
const now = new Date('2022-01-19');
jest.spyOn(controller.vnApp, 'showSuccess');
$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', () => {
controller.filter.scopeDays = 1;
controller.from = new Date();
controller.from = new Date('2022-01-19');
expect(controller.filter.scopeDays).toBeNull();
expect(controller.from).toBeDefined();
@ -26,7 +26,7 @@ describe(' Component vnRequestSearchPanel', () => {
it('should clear the scope days when setting the to property', () => {
controller.filter.scopeDays = 1;
controller.to = new Date();
controller.to = new Date('2022-01-19');
expect(controller.filter.scopeDays).toBeNull();
expect(controller.to).toBeDefined();
@ -35,8 +35,8 @@ describe(' Component vnRequestSearchPanel', () => {
describe('scopeDays() setter', () => {
it('should clear the date range when setting the scopeDays property', () => {
controller.filter.from = new Date();
controller.filter.to = new Date();
controller.filter.from = new Date('2022-01-19');
controller.filter.to = new Date('2022-01-19');
controller.scopeDays = 1;

View File

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

View File

@ -26,9 +26,9 @@ describe('SalesMonitor salesFilter()', () => {
try {
const options = {transaction: tx};
const yesterday = new Date();
const yesterday = new Date('2022-01-19');
yesterday.setHours(0, 0, 0, 0);
const today = new Date();
const today = new Date('2022-01-19');
today.setHours(23, 59, 59, 59);
const ctx = {req: {accessToken: {userId: 9}}, args: {
@ -54,10 +54,10 @@ describe('SalesMonitor salesFilter()', () => {
try {
const options = {transaction: tx};
const yesterday = new Date();
const yesterday = new Date('2022-01-19');
yesterday.setDate(yesterday.getDate() - 1);
yesterday.setHours(0, 0, 0, 0);
const today = new Date();
const today = new Date('2022-01-19');
today.setHours(23, 59, 59, 59);
const ctx = {req: {accessToken: {userId: 9}}, args: {
@ -209,10 +209,10 @@ describe('SalesMonitor salesFilter()', () => {
try {
const options = {transaction: tx};
const yesterday = new Date();
const yesterday = new Date('2022-01-19');
yesterday.setDate(yesterday.getDate() - 1);
yesterday.setHours(0, 0, 0, 0);
const today = new Date();
const today = new Date('2022-01-19');
today.setHours(23, 59, 59, 59);
const ctx = {req: {accessToken: {userId: 18}}, args: {}};
@ -238,10 +238,10 @@ describe('SalesMonitor salesFilter()', () => {
try {
const options = {transaction: tx};
const yesterday = new Date();
const yesterday = new Date('2022-01-19');
yesterday.setDate(yesterday.getDate() - 1);
yesterday.setHours(0, 0, 0, 0);
const today = new Date();
const today = new Date('2022-01-19');
today.setHours(23, 59, 59, 59);
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', () => {
controller.filter.scopeDays = 1;
controller.from = new Date();
controller.from = new Date('2022-01-19');
expect(controller.filter.scopeDays).toBeNull();
expect(controller.from).toBeDefined();
@ -49,7 +49,7 @@ describe('Monitor Component vnMonitorSalesSearchPanel', () => {
it('should clear the scope days when setting the to property', () => {
controller.filter.scopeDays = 1;
controller.to = new Date();
controller.to = new Date('2022-01-19');
expect(controller.filter.scopeDays).toBeNull();
expect(controller.to).toBeDefined();
@ -58,8 +58,8 @@ describe('Monitor Component vnMonitorSalesSearchPanel', () => {
describe('scopeDays() setter', () => {
it('should clear the date range when setting the scopeDays property', () => {
controller.filter.from = new Date();
controller.filter.to = new Date();
controller.filter.from = new Date('2022-01-19');
controller.filter.to = new Date('2022-01-19');
controller.scopeDays = 1;

View File

@ -32,7 +32,7 @@ describe('Component vnMonitorSalesTickets', () => {
let params = controller.fetchParams({
scopeDays: 2
});
const from = new Date();
const from = new Date('2022-01-19');
from.setHours(0, 0, 0, 0);
const to = new Date(from.getTime());
to.setDate(to.getDate() + params.scopeDays);
@ -66,14 +66,14 @@ describe('Component vnMonitorSalesTickets', () => {
describe('compareDate()', () => {
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);
expect(result).toEqual('warning');
});
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);
let result = controller.compareDate(futureDate);
@ -81,7 +81,7 @@ describe('Component vnMonitorSalesTickets', () => {
});
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);
let result = controller.compareDate(pastDate);
@ -99,7 +99,7 @@ describe('Component vnMonitorSalesTickets', () => {
describe('dateRange()', () => {
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();

View File

@ -9,7 +9,7 @@ describe('order new()', () => {
try {
const options = {transaction: tx};
const landed = new Date();
const landed = new Date('2022-01-19');
const addressFk = 6;
const agencyModeFk = 1;
@ -30,7 +30,7 @@ describe('order new()', () => {
try {
const options = {transaction: tx};
const landed = new Date();
const landed = new Date('2022-01-19');
const addressFk = 121;
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() => {
controller.order.agencyModeFk = 999;
controller.order.addressFk = 999;
controller.order.landed = new Date();
controller.order.landed = new Date('2022-01-19');
const expectedAgencies = [{id: 1}, {id: 2}];

View File

@ -26,14 +26,14 @@ describe('Component vnOrderIndex', () => {
describe('compareDate()', () => {
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);
expect(result).toEqual('warning');
});
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);
let result = controller.compareDate(futureDate);
@ -41,7 +41,7 @@ describe('Component vnOrderIndex', () => {
});
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);
let result = controller.compareDate(pastDate);

View File

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

View File

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

View File

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

View File

@ -62,7 +62,7 @@ describe('Component vnRouteIndex', () => {
describe('cloneSelectedRoutes()', () => {
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();
controller.cloneSelectedRoutes();

View File

@ -15,7 +15,7 @@ describe('Route Component vnRoute', () => {
let params = controller.fetchParams({
scopeDays: 2
});
const from = new Date();
const from = new Date('2022-01-19');
from.setHours(0, 0, 0, 0);
const to = new Date(from.getTime());
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', () => {
controller.filter.scopeDays = 1;
controller.from = new Date();
controller.from = new Date('2022-01-19');
expect(controller.filter.scopeDays).toBeNull();
expect(controller.from).toBeDefined();
@ -26,7 +26,7 @@ describe('Route Component vnRouteSearchPanel', () => {
it('should clear the scope days when setting the to property', () => {
controller.filter.scopeDays = 1;
controller.to = new Date();
controller.to = new Date('2022-01-19');
expect(controller.filter.scopeDays).toBeNull();
expect(controller.to).toBeDefined();
@ -35,8 +35,8 @@ describe('Route Component vnRouteSearchPanel', () => {
describe('scopeDays() setter', () => {
it('should clear the date range when setting the scopeDays property', () => {
controller.filter.from = new Date();
controller.filter.to = new Date();
controller.filter.from = new Date('2022-01-19');
controller.filter.to = new Date('2022-01-19');
controller.scopeDays = 1;

View File

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

View File

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

View File

@ -62,7 +62,7 @@ describe('ticket canBeInvoiced()', () => {
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);
await ticket.updateAttribute('shipped', shipped, options);

View File

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

View File

@ -26,9 +26,9 @@ describe('ticket filter()', () => {
try {
const options = {transaction: tx};
const yesterday = new Date();
const yesterday = new Date('2022-01-19');
yesterday.setHours(0, 0, 0, 0);
const today = new Date();
const today = new Date('2022-01-19');
today.setHours(23, 59, 59, 59);
const ctx = {req: {accessToken: {userId: 9}}, args: {
@ -54,10 +54,10 @@ describe('ticket filter()', () => {
try {
const options = {transaction: tx};
const yesterday = new Date();
const yesterday = new Date('2022-01-19');
yesterday.setDate(yesterday.getDate() - 1);
yesterday.setHours(0, 0, 0, 0);
const today = new Date();
const today = new Date('2022-01-19');
today.setHours(23, 59, 59, 59);
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');
describe('ticket new()', () => {
const today = new Date();
const today = new Date('2022-01-19');
const ctx = {req: {accessToken: {userId: 1}}};
it('should throw an error if the client isnt frozen and isnt active', async() => {

View File

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

View File

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

View File

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

View File

@ -43,7 +43,7 @@ describe('Ticket Component vnTicketDescriptorMenu', () => {
describe('canRestoreTicket() getter', () => {
it('should return true for a ticket deleted within the last hour', () => {
controller.ticket.isDeleted = true;
controller.ticket.updated = new Date();
controller.ticket.updated = new Date('2022-01-19');
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', () => {
const pastHour = new Date();
const pastHour = new Date('2022-01-19');
pastHour.setHours(pastHour.getHours() - 2);
controller.ticket.isDeleted = true;

View File

@ -31,14 +31,14 @@ describe('Component vnTicketIndex', () => {
describe('compareDate()', () => {
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);
expect(result).toEqual('warning');
});
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);
let result = controller.compareDate(futureDate);
@ -46,7 +46,7 @@ describe('Component vnTicketIndex', () => {
});
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);
let result = controller.compareDate(pastDate);

View File

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

View File

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

View File

@ -49,7 +49,7 @@ xdescribe('Travel cloneWithEntries()', () => {
it(`should clone the travel and the containing entries`, async() => {
const warehouseThree = 3;
const agencyModeOne = 1;
const yesterday = new Date();
const yesterday = new Date('2022-01-19');
yesterday.setDate(yesterday.getDate() - 1);
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() => {
const from = new Date();
const from = new Date('2022-01-19');
from.setDate(from.getDate() - 2);
from.setHours(0, 0, 0, 0);
const to = new Date();
const to = new Date('2022-01-19');
to.setHours(23, 59, 59, 999);
to.setDate(to.getDate() + 7);
const ctx = {

View File

@ -54,8 +54,8 @@ describe('Travel filter()', () => {
});
it('should return the routes matching "shipped from" and "shipped to"', async() => {
const from = new Date();
const to = new Date();
const from = new Date('2022-01-19');
const to = new Date('2022-01-19');
from.setHours(0, 0, 0, 0);
to.setHours(23, 59, 59, 999);
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.`, () => {
controller.travel = {agencyModeFk: 4};
const tomorrow = new Date();
const tomorrow = new Date('2022-01-19');
const query = `travels/getAverageDays?agencyModeFk=${controller.travel.agencyModeFk}`;
$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.`, () => {
controller.travel = {agencyModeFk: 1};
const tomorrow = new Date();
const tomorrow = new Date('2022-01-19');
tomorrow.setDate(tomorrow.getDate() + 9);
const expectedResponse = {
id: 8,

View File

@ -16,7 +16,7 @@ describe('Travel Component vnTravelExtraCommunity', () => {
describe('hasDateRange()', () => {
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};
const result = controller.hasDateRange;

View File

@ -50,7 +50,7 @@ describe('Travel Component vnTravelIndex', () => {
describe('compareDate()', () => {
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);
@ -58,7 +58,7 @@ describe('Travel Component vnTravelIndex', () => {
});
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);
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', () => {
const yesterday = new Date();
const yesterday = new Date('2022-01-19');
yesterday.setDate(yesterday.getDate() - 1);
const result = controller.compareDate(yesterday);

View File

@ -15,7 +15,7 @@ describe('Travel Component vnTravel', () => {
let params = controller.fetchParams({
scopeDays: 2
});
const shippedFrom = new Date();
const shippedFrom = new Date('2022-01-19');
shippedFrom.setHours(0, 0, 0, 0);
const shippedTo = new Date(shippedFrom.getTime());
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', () => {
controller.filter.scopeDays = 1;
controller.shippedFrom = new Date();
controller.shippedFrom = new Date('2022-01-19');
expect(controller.filter.scopeDays).toBeNull();
expect(controller.shippedFrom).toBeDefined();
@ -26,7 +26,7 @@ describe('Travel Component vnTravelSearchPanel', () => {
it('should clear the scope days when setting the to property', () => {
controller.filter.scopeDays = 1;
controller.shippedTo = new Date();
controller.shippedTo = new Date('2022-01-19');
expect(controller.filter.scopeDays).toBeNull();
expect(controller.shippedTo).toBeDefined();
@ -35,8 +35,8 @@ describe('Travel Component vnTravelSearchPanel', () => {
describe('scopeDays() setter', () => {
it('should clear the date range when setting the scopeDays property', () => {
controller.filter.shippedFrom = new Date();
controller.filter.shippedTo = new Date();
controller.filter.shippedFrom = new Date('2022-01-19');
controller.filter.shippedTo = new Date('2022-01-19');
controller.scopeDays = 1;

View File

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

View File

@ -3,9 +3,9 @@ const app = require('vn-loopback/server/server');
describe('workerTimeControl filter()', () => {
it('should return 1 result filtering by id', async() => {
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);
const lastHour = new Date();
const lastHour = new Date('2022-01-19');
lastHour.setDate(lastHour.getDate() + 1);
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() => {
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);
const lastHour = new Date();
const lastHour = new Date('2022-01-19');
lastHour.setDate(lastHour.getDate() + 1);
lastHour.setHours(15, 0, 0, 0);

View File

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

View File

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

View File

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

View File

@ -3,10 +3,10 @@ const models = require('vn-loopback/server/server').models;
describe('Worker getWorkedHours()', () => {
it(`should return the expected hours and the worked hours of a given date`, async() => {
const workerID = 1106;
const started = new Date();
const started = new Date('2022-01-19');
started.setHours(0, 0, 0, 0);
const ended = new Date();
const ended = new Date('2022-01-19');
ended.setHours(23, 59, 59, 999);
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() => {
const now = new Date();
const now = new Date('2022-01-19');
const year = now.getFullYear();
ctx.args = {businessFk: businessId, year: year};

View File

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

View File

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

View File

@ -18,7 +18,7 @@ describe('Component vnWorkerTimeControl', () => {
describe('date() setter', () => {
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();
controller.date = today;
@ -33,7 +33,7 @@ describe('Component vnWorkerTimeControl', () => {
describe('hours() setter', () => {
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();
controller.date = today;
@ -64,7 +64,7 @@ describe('Component vnWorkerTimeControl', () => {
describe('getWorkedHours() ', () => {
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();
controller.date = today;
@ -117,7 +117,7 @@ describe('Component vnWorkerTimeControl', () => {
describe('save() ', () => {
it(`should make a query an then call to the fetchHours() method`, () => {
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 = {
hide: () => {}
};

View File

@ -1,7 +1,7 @@
const app = require('vn-loopback/server/server');
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() => {
const tx = await app.models.Zone.beginTransaction({});

View File

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

View File

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

View File

@ -1,7 +1,7 @@
const app = require('vn-loopback/server/server');
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() => {
const tx = await app.models.Agency.beginTransaction({});

View File

@ -6,7 +6,7 @@ describe('zone getZoneClosing()', () => {
try {
const options = {transaction: tx};
const date = new Date();
const date = new Date('2022-01-19');
const today = date.toISOString().split('T')[0];
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() => {
const ctx = {req: {accessToken: {userId: 1}}};
const where = {
shipped: new Date(),
shipped: new Date('2022-01-19'),
addressFk: addressId,
agencyModeFk: inhousePickupId,
warehouseFk: warehouseId

View File

@ -21,7 +21,7 @@ describe('component vnZoneCalendar', () => {
it('should set the month property and then call the refreshEvents() method', () => {
jest.spyOn(controller, 'refreshEvents').mockReturnThis();
controller.date = new Date();
controller.date = new Date('2022-01-19');
expect(controller.refreshEvents).toHaveBeenCalledWith();
expect(controller.months.length).toEqual(4);
@ -30,7 +30,7 @@ describe('component vnZoneCalendar', () => {
describe('step()', () => {
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.setMonth(now.getMonth() - 4);
@ -43,7 +43,7 @@ describe('component vnZoneCalendar', () => {
});
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.setMonth(now.getMonth() + 4);
@ -62,10 +62,10 @@ describe('component vnZoneCalendar', () => {
controller.data = {
exclusions: [{
dated: new Date()
dated: new Date('2022-01-19')
}],
events: [{
dated: new Date()
dated: new Date('2022-01-19')
}]
};
@ -80,9 +80,9 @@ describe('component vnZoneCalendar', () => {
describe('refreshEvents()', () => {
it('should fill the days property with the events.', () => {
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);
controller.lastDay = lastDay;
@ -109,7 +109,7 @@ describe('component vnZoneCalendar', () => {
jest.spyOn(controller, 'emit');
const $event = {};
const $days = [new Date()];
const $days = [new Date('2022-01-19')];
const $type = 'day';
const $weekday = 1;
@ -130,7 +130,7 @@ describe('component vnZoneCalendar', () => {
describe('hasEvents()', () => {
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;
@ -142,7 +142,7 @@ describe('component vnZoneCalendar', () => {
describe('getClass()', () => {
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[dated.getTime()] = true;

View File

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

View File

@ -65,7 +65,7 @@ describe('component vnZoneEvents', () => {
it('should call the create() method', () => {
jest.spyOn(controller, 'create').mockReturnThis();
const weekday = {dated: new Date()};
const weekday = {dated: new Date('2022-01-19')};
const days = [weekday];
const type = 'EventType';
const events = [];
@ -94,7 +94,7 @@ describe('component vnZoneEvents', () => {
jest.spyOn(controller, 'exclusionCreate').mockReturnThis();
const weekday = {};
const days = [{dated: new Date()}];
const days = [{dated: new Date('2022-01-19')}];
const type = 'EventType';
const events = [];
const exclusions = [];
@ -110,7 +110,7 @@ describe('component vnZoneEvents', () => {
controller.$.dialog = {show: jest.fn()};
const type = 'weekday';
const days = [new Date()];
const days = [new Date('2022-01-19')];
const weekday = 1;
controller.create(type, days, weekday);
@ -127,7 +127,7 @@ describe('component vnZoneEvents', () => {
controller.$.dialog = {show: jest.fn()};
const type = 'nonListedType';
const days = [new Date()];
const days = [new Date('2022-01-19')];
const weekday = 1;
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', () => {
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});
controller.exclusionCreate(dates);
$httpBackend.flush();