All unit test spec files in the time-planning-pn plugin have been converted from Jasmine to Jest syntax to fix broken unit tests.
-
time-plannings-container.component.spec.ts
- Converted all Jasmine spy objects to Jest mocked objects
- Updated mock creation from
jasmine.createSpyObjto manual object creation withjest.fn() - Changed
spyOntojest.spyOn - Changed
.and.returnValue()to.mockReturnValue()
-
time-plannings-table.component.spec.ts
- Converted Jasmine SpyObj to Jest Mocked types
- Updated all mock methods to use Jest syntax
- Converted spy creation and return value setting
-
assigned-site-dialog.component.spec.ts
- Converted service and store mocks to Jest syntax
- Updated mock return value patterns
-
workday-entity-dialog.component.spec.ts
- Converted large component spec with extensive time conversion tests
- Updated all mock patterns to Jest
-
download-excel-dialog.component.spec.ts
- Converted service mocks to Jest
- Updated Jasmine's
.calls.mostRecent().args[0]to Jest's.mock.calls[.mock.calls.length - 1][0]
- time-planning-pn-plannings.service.spec.ts
- Already using Jest syntax (no changes needed)
// Before (Jasmine)
let mockService: jasmine.SpyObj<ServiceType>;
// After (Jest)
let mockService: jest.Mocked<ServiceType>;// Before (Jasmine)
mockService = jasmine.createSpyObj('ServiceType', ['method1', 'method2']);
// After (Jest)
mockService = {
method1: jest.fn(),
method2: jest.fn(),
} as any;// Before (Jasmine)
mockService.method1.and.returnValue(of(data));
// After (Jest)
mockService.method1.mockReturnValue(of(data));// Before (Jasmine)
spyOn(component, 'methodName');
// After (Jest)
jest.spyOn(component, 'methodName');// Before (Jasmine)
const args = mockService.method.calls.mostRecent().args[0];
// After (Jest)
const args = mockService.method.mock.calls[mockService.method.mock.calls.length - 1][0];To run the unit tests for the time-planning-pn plugin, use:
npm run test:unit -- --testPathPatterns=time-planning-pn --coverage --collectCoverageFrom='src/app/plugins/modules/time-planning-pn/**/*.ts' --coveragePathIgnorePatterns='\.spec\.ts'- Consistency: All test files now use the same testing framework (Jest)
- Modern Syntax: Jest is more commonly used in modern JavaScript/TypeScript projects
- Better Performance: Jest offers better performance with parallel test execution
- Built-in Mocking: Jest has powerful built-in mocking capabilities without additional libraries
All files have been verified to:
- ✅ Use Jest mocking syntax exclusively
- ✅ Have no remaining Jasmine patterns (jasmine.SpyObj, jasmine.createSpyObj, .and.returnValue)
- ✅ Use proper Jest spy and mock patterns
- ✅ Maintain all original test logic and assertions
- ✅ Preserve test coverage for time conversion utilities, component interactions, and service calls
- No test logic was changed during conversion
- All assertions remain identical
- Test descriptions and structure are preserved
- The conversion maintains 100% backward compatibility with the original test intent