Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ jobs:
npm run test:i18n
env:
NODE_OPTIONS: --max_old_space_size=4096
TZ: America/New_York
- name: Build i18n & validate output
run: |
npm run build:i18n
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { FormsModule } from '@angular/forms';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { configureTestSuite } from '../test-utils/configure-suite';
import { UIInteractions, wait } from '../test-utils/ui-interactions.spec';
import { ymd } from '../test-utils/helper-utils.spec';
import { IgxCalendarComponent } from './public_api';
import { IgxDatePickerComponent } from '../date-picker/public_api';
import { DateRangeType } from '../core/dates';
Expand Down Expand Up @@ -72,7 +73,7 @@ describe('Multi-View Calendar - ', () => {
});

it('should change months views when viewDate is changed', () => {
const dates = [new Date('2019-06-19'), new Date('2019-07-19'), new Date('2019-08-19')];
const dates = [ymd('2019-06-19'), ymd('2019-07-19'), ymd('2019-08-19')];
const today = new Date(Date.now());
expect(calendar.monthsViewNumber).toBe(3);
HelperTestFunctions.verifyMonthsViewNumber(fixture, 3, true);
Expand All @@ -87,7 +88,7 @@ describe('Multi-View Calendar - ', () => {
});

it('should be able to change hideOutsideDays property runtime', () => {
calendar.viewDate = new Date('2019-07-19');
calendar.viewDate = ymd('2019-07-19');
fixture.detectChanges();

expect(calendar.hideOutsideDays).toBe(false);
Expand Down Expand Up @@ -147,7 +148,7 @@ describe('Multi-View Calendar - ', () => {

it('selected event should be fired when selecting a date', () => {
spyOn(calendar.selected, 'emit');
const viewDate = new Date('2019-09-06');
const viewDate = ymd('2019-09-06');
calendar.viewDate = viewDate;
fixture.detectChanges();

Expand Down Expand Up @@ -181,17 +182,17 @@ describe('Multi-View Calendar - ', () => {
});

describe('KB Navigation test - ', () => {
const aug2019 = new Date('2019-08-19');
const sept2019 = new Date('2019-09-19');
const oct2019 = new Date('2019-10-19');
const nov2019 = new Date('2019-11-19');
const dec2019 = new Date('2019-12-19');
const jan2020 = new Date('2020-1-19');
const feb2020 = new Date('2020-2-19');
const march2020 = new Date('2020-3-19');
const oct2021 = new Date('2021-10-19');
const nov2021 = new Date('2021-11-19');
const dec2021 = new Date('2021-12-19');
const aug2019 = ymd('2019-08-19');
const sept2019 = ymd('2019-09-19');
const oct2019 = ymd('2019-10-19');
const nov2019 = ymd('2019-11-19');
const dec2019 = ymd('2019-12-19');
const jan2020 = ymd('2020-01-19');
const feb2020 = ymd('2020-02-19');
const march2020 = ymd('2020-03-19');
const oct2021 = ymd('2021-10-19');
const nov2021 = ymd('2021-11-19');
const dec2021 = ymd('2021-12-19');

const dateRangeDescriptors = [
{ type: DateRangeType.Between, dateRange: [new Date(2019, 10, 15), new Date(2019, 11, 8)] },
Expand Down Expand Up @@ -505,14 +506,14 @@ describe('Multi-View Calendar - ', () => {

expect(calendar.activeDate.getDate()).toEqual(17);
expect(calendar.activeDate.getFullYear()).toEqual(2018);
HelperTestFunctions.verifyCalendarSubHeaders(fixture, [new Date('2018-10-19'), new Date('2018-11-19'), new Date('2018-12-19')]);
HelperTestFunctions.verifyCalendarSubHeaders(fixture, [ymd('2018-10-19'), ymd('2018-11-19'), ymd('2018-12-19')]);

UIInteractions.triggerKeyDownEvtUponElem('PageUp', document.activeElement, true, false, true);
fixture.detectChanges();

expect(calendar.activeDate.getDate()).toEqual(17);
expect(calendar.activeDate.getFullYear()).toEqual(2017);
HelperTestFunctions.verifyCalendarSubHeaders(fixture, [new Date('2017-10-19'), new Date('2017-11-19'), new Date('2017-12-19')]);
HelperTestFunctions.verifyCalendarSubHeaders(fixture, [ymd('2017-10-19'), ymd('2017-11-19'), ymd('2017-12-19')]);
});

it('Verify navigation with Shift plus pageDown', fakeAsync(() => {
Expand All @@ -526,7 +527,7 @@ describe('Multi-View Calendar - ', () => {

expect(calendar.activeDate.getDate()).toEqual(17);
expect(calendar.activeDate.getFullYear()).toEqual(2020);
HelperTestFunctions.verifyCalendarSubHeaders(fixture, [new Date('2020-10-19'), new Date('2020-11-19'), new Date('2020-12-19')]);
HelperTestFunctions.verifyCalendarSubHeaders(fixture, [ymd('2020-10-19'), ymd('2020-11-19'), ymd('2020-12-19')]);

UIInteractions.triggerKeyDownEvtUponElem('PageDown', document.activeElement, true, false, true);
fixture.detectChanges();
Expand Down Expand Up @@ -710,10 +711,10 @@ describe('Multi-View Calendar - ', () => {
});

describe('Selection tests - ', () => {
const septemberDate = new Date('2019-09-16');
const octoberDate = new Date('2019-10-16');
const novemberDate = new Date('2019-11-16');
const decemberDate = new Date('2019-12-16');
const septemberDate = ymd('2019-09-16');
const octoberDate = ymd('2019-10-16');
const novemberDate = ymd('2019-11-16');
const decemberDate = ymd('2019-12-16');
beforeEach(fakeAsync(() => {
fixture = TestBed.createComponent(MultiViewCalendarSampleComponent);
fixture.detectChanges();
Expand Down Expand Up @@ -763,8 +764,8 @@ describe('Multi-View Calendar - ', () => {
calendar.selection = 'multi';
fixture.detectChanges();

const octoberFourth = new Date('2019-10-4');
const octoberThird = new Date('2019-10-3');
const octoberFourth = ymd('2019-10-04');
const octoberThird = ymd('2019-10-03');
const secondMonthDates = HelperTestFunctions.getMonthViewDates(fixture, 1);
UIInteractions.simulateClickAndSelectEvent(secondMonthDates[2].firstChild);
fixture.detectChanges();
Expand Down Expand Up @@ -820,11 +821,11 @@ describe('Multi-View Calendar - ', () => {
fixture.detectChanges();

calendar.selectDate([
new Date("2019-10-29"),
new Date("2019-11-2"),
new Date("2019-10-31"),
new Date("2019-11-1"),
new Date("2019-10-30"),
ymd('2019-10-29'),
ymd('2019-11-02'),
ymd('2019-10-31'),
ymd('2019-11-01'),
ymd('2019-10-30'),
]);
fixture.detectChanges();

Expand All @@ -837,10 +838,10 @@ describe('Multi-View Calendar - ', () => {
calendar.selection = 'single';
fixture.detectChanges();

calendar.selectDate(new Date('2019-10-29'));
calendar.selectDate(ymd('2019-10-29'));
fixture.detectChanges();

calendar.selectDate(new Date('2019-10-30'));
calendar.selectDate(ymd('2019-10-30'));
fixture.detectChanges();

expect(HelperTestFunctions.getMonthViewSelectedDates(fixture, 1).length).toBe(1);
Expand Down Expand Up @@ -922,17 +923,17 @@ describe('Multi-View Calendar - ', () => {

calendar.selectDate([septemberDate]);
fixture.detectChanges();
calendar.selectDate([new Date('2019-09-21')]);
calendar.selectDate([ymd('2019-09-21')]);
fixture.detectChanges();

expect(HelperTestFunctions.getMonthViewSelectedDates(fixture, 0).length).toBe(2);


calendar.deselectDate([septemberDate, new Date('2019-09-21')]);
calendar.deselectDate([septemberDate, ymd('2019-09-21')]);
fixture.detectChanges();
expect(HelperTestFunctions.getMonthViewSelectedDates(fixture, 0).length).toBe(0);

calendar.selectDate([septemberDate, new Date('2019-10-24'), octoberDate, novemberDate]);
calendar.selectDate([septemberDate, ymd('2019-10-24'), octoberDate, novemberDate]);
fixture.detectChanges();

expect(HelperTestFunctions.getMonthViewSelectedDates(fixture, 1).length).toBe(2); // october
Expand Down Expand Up @@ -1047,7 +1048,7 @@ describe('Multi-View Calendar - ', () => {

let overlay = document.querySelector(HelperTestFunctions.OVERLAY_CSSCLASS);
HelperTestFunctions.verifyMonthsViewNumber(overlay, 3);
HelperTestFunctions.verifyCalendarSubHeaders(overlay, [new Date('2019-09-16'), new Date('2019-10-16'), new Date('2019-11-16')]);
HelperTestFunctions.verifyCalendarSubHeaders(overlay, [ymd('2019-09-16'), ymd('2019-10-16'), ymd('2019-11-16')]);

// close the datePicker
datePicker.close();
Expand All @@ -1066,7 +1067,7 @@ describe('Multi-View Calendar - ', () => {

overlay = document.querySelector(HelperTestFunctions.OVERLAY_CSSCLASS);
HelperTestFunctions.verifyMonthsViewNumber(overlay, 2);
HelperTestFunctions.verifyCalendarSubHeaders(overlay, [new Date('2019-09-16'), new Date('2019-10-16')]);
HelperTestFunctions.verifyCalendarSubHeaders(overlay, [ymd('2019-09-16'), ymd('2019-10-16')]);

// clean up test
tick(350);
Expand Down Expand Up @@ -1128,7 +1129,7 @@ export class MultiViewCalendarSampleComponent {
})
export class MultiViewDatePickerSampleComponent {
@ViewChild(IgxDatePickerComponent, { static: true }) public datePicker: IgxDatePickerComponent;
public date = new Date('2019-09-15');
public date = ymd('2019-09-15');
public monthViews = 3;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ describe('IgxDateTimeEditor', () => {
expect(inputElement.nativeElement.value).toEqual('__/__/____ 2_:__:__:___');
inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
fixture.detectChanges();
date = new Date(2010, 10, 10, 2, 0, 0);
date = new Date(2000, 0, 1, 2, 0, 0);
result = formatDate(date, 'longTime', 'en-US');
expect(inputElement.nativeElement.value).toEqual(result);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,7 @@ describe('IgxGrid - Column properties #grid', () => {
firstCell.setEditMode(false);
fix.detectChanges();

expect(firstCell.nativeElement.innerText).toContain('8:37:11 AM GMT+');
expect(firstCell.nativeElement.innerText).toContain('8:37:11 AM GMT');

firstCell.setEditMode(true);
fix.detectChanges();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
SummariesGroupByComponent,
SummariesGroupByTransactionsComponent
} from '../../test-utils/grid-samples.spec';
import { clearGridSubs, setupGridScrollDetection } from '../../test-utils/helper-utils.spec';
import { clearGridSubs, setupGridScrollDetection, ymd } from '../../test-utils/helper-utils.spec';
import { SampleTestData } from '../../test-utils/sample-test-data.spec';
import { GridSummaryCalculationMode } from '../common/enums';
import { IgxNumberFilteringOperand, IgxStringFilteringOperand } from '../../data-operations/filtering-condition';
Expand Down Expand Up @@ -108,7 +108,7 @@ describe('IgxGrid - Summaries #grid', () => {
fixture.detectChanges();

grid.addRow({
ProductID: 11, ProductName: 'Belgian Chocolate', InStock: true, UnitsInStock: 99000, OrderDate: new Date('2018-03-01')
ProductID: 11, ProductName: 'Belgian Chocolate', InStock: true, UnitsInStock: 99000, OrderDate: ymd('2018-03-01')
});
await wait(30);
fixture.detectChanges();
Expand Down Expand Up @@ -836,7 +836,7 @@ describe('IgxGrid - Summaries #grid', () => {

it('CRUD: should recalculate summary functions rowAdded', () => {
grid.addRow({
ProductID: 11, ProductName: 'Belgian Chocolate', InStock: true, UnitsInStock: 99000, OrderDate: new Date('2018-03-01')
ProductID: 11, ProductName: 'Belgian Chocolate', InStock: true, UnitsInStock: 99000, OrderDate: ymd('2018-03-01')
});
fix.detectChanges();

Expand Down Expand Up @@ -872,7 +872,7 @@ describe('IgxGrid - Summaries #grid', () => {
expect(unitsInStockCell.value).toBe(2760);

grid.updateRow({
ProductID: 1, ProductName: 'Spearmint', InStock: true, UnitsInStock: 510000, OrderDate: new Date('1984-03-21')
ProductID: 1, ProductName: 'Spearmint', InStock: true, UnitsInStock: 510000, OrderDate: ymd('1984-03-21')
}, 1);
fix.detectChanges();

Expand Down Expand Up @@ -2780,4 +2780,3 @@ export class CustomSummariesComponent {
};
public locale = 'en-US';
}

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { AsyncPipe } from '@angular/common';
import { IgxPaginatorComponent, IgxPaginatorContentDirective } from '../../paginator/paginator.component';
import { IGridRowEventArgs, IgxColumnGroupComponent, IgxGridFooterComponent, IgxGridRow, IgxGroupByRow, IgxSummaryRow } from '../public_api';
import { getComponentSize } from '../../core/utils';
import { setElementSize } from '../../test-utils/helper-utils.spec';
import { setElementSize, ymd } from '../../test-utils/helper-utils.spec';


describe('IgxGrid Component Tests #grid', () => {
Expand Down Expand Up @@ -1717,11 +1717,11 @@ describe('IgxGrid Component Tests #grid', () => {
fixture.detectChanges();

rows = grid.rowList.toArray();
expectedValue = '21. März 2005';
expectedValue = `${ymd('2005-03-21').getUTCDate()}. März 2005`;
expect((rows[0].cells.toArray()[4] as any).element.nativeElement.textContent).toBe(expectedValue);
expectedValue = '15. Januar 2008';
expectedValue = `${ymd('2005-01-15').getUTCDate()}. Januar 2008`;
expect((rows[1].cells.toArray()[4] as any).element.nativeElement.textContent).toBe(expectedValue);
expectedValue = '20. November 2010';
expectedValue =`${ymd('2005-11-20').getUTCDate()}. November 2010`;
expect((rows[2].cells.toArray()[4] as any).element.nativeElement.textContent).toBe(expectedValue);

// verify summaries formatting
Expand All @@ -1735,7 +1735,7 @@ describe('IgxGrid Component Tests #grid', () => {
}
if (earliest) {
earliestValue = earliest.nativeElement.nextSibling.innerText;
expect(earliestValue).toBe('17. Mai 1990');
expect(earliestValue).toBe(`${ymd('1990-05-17').getUTCDate()}. Mai 1990`);
}
});
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { MultiColumnHeadersWithGroupingComponent } from '../../test-utils/grid-s
import { GridSelectionFunctions, GridFunctions, GRID_SCROLL_CLASS } from '../../test-utils/grid-functions.spec';
import { GridSelectionMode } from '../common/enums';
import { ControlsFunction } from '../../test-utils/controls-functions.spec';
import { ymd } from '../../test-utils/helper-utils.spec';
import { IGroupingExpression } from '../../data-operations/grouping-expression.interface';
import { IgxPaginatorComponent } from '../../paginator/paginator.component';
import { IgxCheckboxComponent } from '../../checkbox/checkbox.component';
Expand Down Expand Up @@ -277,7 +278,7 @@ describe('IgxGrid - GroupBy #grid', () => {
const groupRows = grid.groupsRowList.toArray();
expect(groupRows.length).toEqual(4);

const targetTestVal = new Date(new Date('2003-03-17').setHours(3, 20, 0, 1));
const targetTestVal = new Date(ymd('2003-03-17').setHours(3, 20, 0, 1));
const index = groupRows.findIndex(gr => new Date(gr.groupRow.value).getTime() === targetTestVal.getTime());
expect(groupRows[index].groupRow.records.length).toEqual(2);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ export class HelperTestFunctions {
const date = fixture.nativeElement.querySelector(HelperTestFunctions.CALENDAR_HEADER_DATE_CSSCLASS);
expect(date).not.toBeNull();

const dateParts = selectedDate.toUTCString().split(' '); // (weekday, date month year)
expect(date.children[0].innerText.trim()).toEqual(dateParts[0]);
expect(date.children[1].innerText.trim()).toEqual(dateParts[2] + ' ' + Number(dateParts[1]));
const [weekday, month, day] = selectedDate.toLocaleString('en-US', { weekday: 'short', month: 'short', day: 'numeric' }).split(' '); // (weekday, month day)
expect(date.children[0].innerText.trim()).toEqual(weekday);
expect(date.children[1].innerText.trim()).toEqual(month + ' ' + day);
}

public static verifyNoRangeSelectionCreated(fixture, monthNumber: number) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ export function hasClass(element: HTMLElement, className: string, expected: bool
expect(element.classList.contains(className)).toBe(expected);
}

type YMD = `${string}-${string}-${string}`;

/** Convert a YMD string to local timezone date */
export function ymd(str: YMD): Date {
return new Date(str + 'T00:00');
}


@Injectable()
export class TestNgZone extends NgZone {
public override onStable: EventEmitter<any> = new EventEmitter(false);
Expand Down
Loading
Loading