refactor: migrate testing framework from Karma/Jasmine to Vitest with Angular support
This commit is contained in:
1 parent
237d995e16
commit
11924df19e
14 files changed
+1351
-273
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { vi } from 'vitest';
|
||||
import { provideZonelessChangeDetection } from '@angular/core';
|
||||
import {
|
||||
CalendarService,
|
||||
@@ -228,20 +229,20 @@ describe('SelectedDates', () => {
|
||||
{ id: '3', type: RuleType.IF_THEN, enabled: true } as IfThenRule,
|
||||
];
|
||||
|
||||
const applyTimeWindowRulesSpy = spyOn(selectedDates, 'applyTimeWindowRules');
|
||||
const applyIfThenRulesSpy = spyOn(selectedDates, 'applyIfThenRules');
|
||||
const applyTimeWindowRulesSpy = vi.spyOn(selectedDates, 'applyTimeWindowRules');
|
||||
const applyIfThenRulesSpy = vi.spyOn(selectedDates, 'applyIfThenRules');
|
||||
|
||||
await selectedDates.optimizeVacations(vacationDays, rules, calendarService);
|
||||
|
||||
expect(applyIfThenRulesSpy.calls.count()).toBe(2);
|
||||
expect(applyTimeWindowRulesSpy.calls.count()).toBe(1);
|
||||
expect(applyIfThenRulesSpy.mock.calls.length).toBe(2);
|
||||
expect(applyTimeWindowRulesSpy.mock.calls.length).toBe(1);
|
||||
|
||||
// First rule is IF_THEN
|
||||
expect(applyIfThenRulesSpy.calls.argsFor(0)[1][0].id).toBe('1');
|
||||
expect(applyIfThenRulesSpy.mock.calls[0][1][0].id).toBe('1');
|
||||
// Second rule is TIME_WINDOW
|
||||
expect(applyTimeWindowRulesSpy.calls.argsFor(0)[1][0].id).toBe('2');
|
||||
expect(applyTimeWindowRulesSpy.mock.calls[0][1][0].id).toBe('2');
|
||||
// Third rule is IF_THEN
|
||||
expect(applyIfThenRulesSpy.calls.argsFor(1)[1][0].id).toBe('3');
|
||||
expect(applyIfThenRulesSpy.mock.calls[1][1][0].id).toBe('3');
|
||||
});
|
||||
|
||||
it('should apply time window rules', () => {
|
||||
@@ -268,7 +269,7 @@ describe('SelectedDates', () => {
|
||||
];
|
||||
|
||||
// Mock monthsInAYearFromNow to return a controlled range of days
|
||||
spyOn(calendarService, 'monthsInAYearFromNow').and.returnValue([
|
||||
vi.spyOn(calendarService, 'monthsInAYearFromNow').mockReturnValue([
|
||||
[
|
||||
[
|
||||
new Date(futureYear, 11, 20),
|
||||
@@ -376,7 +377,7 @@ describe('SelectedDates', () => {
|
||||
},
|
||||
];
|
||||
|
||||
spyOn(calendarService, 'monthsInAYearFromNow').and.returnValue([
|
||||
vi.spyOn(calendarService, 'monthsInAYearFromNow').mockReturnValue([
|
||||
[
|
||||
[
|
||||
new Date(futureYear, 6, 1),
|
||||
|
||||
Reference in new issue
Block a user