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,6 +1,7 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { provideZonelessChangeDetection } from '@angular/core';
|
||||
import { MatDialogRef } from '@angular/material/dialog';
|
||||
import { vi } from 'vitest';
|
||||
import { CalendarSettingsDialog } from './calendar-settings-dialog';
|
||||
|
||||
describe('CalendarSettingsDialog', () => {
|
||||
@@ -15,7 +16,7 @@ describe('CalendarSettingsDialog', () => {
|
||||
{
|
||||
provide: MatDialogRef,
|
||||
useValue: {
|
||||
close: jasmine.createSpy('close'),
|
||||
close: vi.fn(),
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
@@ -33,7 +33,7 @@ describe('RulesPanel', () => {
|
||||
it('should start adding new If-Then rule', () => {
|
||||
component.startAddNew(RuleType.IF_THEN);
|
||||
|
||||
expect(component['isAddingNew']()).toBeTrue();
|
||||
expect(component['isAddingNew']()).toBe(true);
|
||||
expect(component['newRuleType']()).toBe(RuleType.IF_THEN);
|
||||
expect(component['editBuffer'].type).toBe(RuleType.IF_THEN);
|
||||
expect(component['editBuffer'].name).toBe('Nouvelle Règle');
|
||||
@@ -42,7 +42,7 @@ describe('RulesPanel', () => {
|
||||
it('should start adding new Time Window rule', () => {
|
||||
component.startAddNew(RuleType.TIME_WINDOW);
|
||||
|
||||
expect(component['isAddingNew']()).toBeTrue();
|
||||
expect(component['isAddingNew']()).toBe(true);
|
||||
expect(component['newRuleType']()).toBe(RuleType.TIME_WINDOW);
|
||||
expect(component['editBuffer'].type).toBe(RuleType.TIME_WINDOW);
|
||||
expect(component['editBuffer'].name).toBe('Nouvelle Période');
|
||||
@@ -52,7 +52,7 @@ describe('RulesPanel', () => {
|
||||
component.startAddNew(RuleType.IF_THEN);
|
||||
component.cancelEdit();
|
||||
|
||||
expect(component['isAddingNew']()).toBeFalse();
|
||||
expect(component['isAddingNew']()).toBe(false);
|
||||
expect(component['editingRuleId']()).toBeNull();
|
||||
expect(Object.keys(component['editBuffer']).length).toBe(0);
|
||||
});
|
||||
@@ -65,7 +65,7 @@ describe('RulesPanel', () => {
|
||||
component.saveEdit();
|
||||
|
||||
expect(component.rules.length).toBe(initialCount + 1);
|
||||
expect(component.rules.some((r) => r.name === 'Custom Test Rule')).toBeTrue();
|
||||
expect(component.rules.some((r) => r.name === 'Custom Test Rule')).toBe(true);
|
||||
});
|
||||
|
||||
it('should update an existing rule', () => {
|
||||
@@ -89,7 +89,7 @@ describe('RulesPanel', () => {
|
||||
component.deleteRule(targetId, mockEvent);
|
||||
|
||||
expect(component.rules.length).toBe(initialCount - 1);
|
||||
expect(component.rules.some((r) => r.id === targetId)).toBeFalse();
|
||||
expect(component.rules.some((r) => r.id === targetId)).toBe(false);
|
||||
});
|
||||
|
||||
it('should toggle a rule', () => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Component, ChangeDetectionStrategy, inject, signal } from '@angular/core';
|
||||
import { Component, ChangeDetectionStrategy, inject, signal, Injectable } from '@angular/core';
|
||||
import {
|
||||
RuleService,
|
||||
RuleType,
|
||||
@@ -26,6 +26,7 @@ import {
|
||||
} from '@angular/material/core';
|
||||
import { CdkDragDrop, CdkDropList, CdkDrag } from '@angular/cdk/drag-drop';
|
||||
|
||||
@Injectable()
|
||||
class CustomDateAdapter extends NativeDateAdapter {
|
||||
override format(date: Date, displayFormat: unknown): string {
|
||||
if (displayFormat === 'input') {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Component, input, output, ChangeDetectionStrategy } from '@angular/core';
|
||||
import { Component, input, output, ChangeDetectionStrategy, Injectable } from '@angular/core';
|
||||
import { SelectableDayType, tooltipTypeMapping, VacDay } from '../../../services/calendar-service';
|
||||
import { MatCard } from '@angular/material/card';
|
||||
import { MatOption, MatSelect } from '@angular/material/select';
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
|
||||
@Injectable()
|
||||
class CustomDateAdapter extends NativeDateAdapter {
|
||||
override format(date: Date, displayFormat: unknown): string {
|
||||
if (displayFormat === 'input') {
|
||||
|
||||
Reference in new issue
Block a user