Skip to content

Commit 1b270cd

Browse files
authored
Merge pull request #14713 from IgniteUI/sstoychev/days-view-tests-172
test(calendar): making tests independent of current calendar date - 17.2
2 parents 95acb7d + 82efc8b commit 1b270cd

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

projects/igniteui-angular/src/lib/calendar/days-view/days-view.component.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { CalendarDay } from "../common/model";
88
import { DateRangeDescriptor, DateRangeType } from "igniteui-webcomponents";
99
import { ScrollDirection } from "../calendar";
1010

11+
const TODAY = new Date(2024, 6, 12);
12+
1113
describe("Days View Component", () => {
1214
configureTestSuite();
1315
const baseClass = "igx-days-view";
@@ -71,10 +73,9 @@ describe("Days View Component", () => {
7173
});
7274

7375
it("should set activeDate to the first day of the current month when no value is provided", () => {
74-
const today = new Date();
7576
const firstMonthDay = new Date(
76-
today.getFullYear(),
77-
today.getMonth(),
77+
TODAY.getFullYear(),
78+
TODAY.getMonth(),
7879
1,
7980
);
8081
const fixture = TestBed.createComponent(InitDaysViewComponent);
@@ -115,12 +116,11 @@ describe("Days View Component", () => {
115116
let fixture: ComponentFixture<InitDaysViewComponent>;
116117
let el: HTMLElement;
117118
let instance: IgxDaysViewComponent;
118-
const today = new Date();
119119
const firstDay = CalendarDay.from(
120-
new Date(today.getFullYear(), today.getMonth(), 1),
120+
new Date(TODAY.getFullYear(), TODAY.getMonth(), 1),
121121
);
122122
const lastDay = CalendarDay.from(
123-
new Date(today.getFullYear(), today.getMonth() + 1, 0),
123+
new Date(TODAY.getFullYear(), TODAY.getMonth() + 1, 0),
124124
);
125125

126126
beforeEach(waitForAsync(() => {
@@ -397,13 +397,13 @@ function getInactiveDays(fixture: ComponentFixture<InitDaysViewComponent>) {
397397
class InitDaysViewComponent {
398398
@ViewChild(IgxDaysViewComponent, { static: true })
399399
public instance: IgxDaysViewComponent;
400-
protected date = new Date();
400+
public date = TODAY;
401401
protected disabledDates: DateRangeDescriptor[] = [
402402
{
403403
type: DateRangeType.Specific,
404404
dateRange: [
405-
new Date(this.date.getFullYear(), this.date.getMonth(), 12),
406-
new Date(this.date.getFullYear(), this.date.getMonth(), 24),
405+
new Date(TODAY.getFullYear(), TODAY.getMonth(), 12),
406+
new Date(TODAY.getFullYear(), TODAY.getMonth(), 24),
407407
],
408408
},
409409
];

0 commit comments

Comments
 (0)