-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update create-initial-data.seed.spec.ts
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -225,4 +225,38 @@ describe('createInitialData', () => { | |
// Verify error was logged | ||
expect(console.error).toHaveBeenCalledWith('Error creating initial data:', hashError); | ||
}); | ||
|
||
it('should use default phone number when EMPLOYEE_PHONE is not set', async () => { | ||
// Remove EMPLOYEE_PHONE from environment | ||
delete process.env.EMPLOYEE_PHONE; | ||
|
||
// Mock that employee doesn't exist | ||
(mockUserRepository.findOne as jest.Mock).mockResolvedValue(null); | ||
|
||
// Mock created services | ||
const mockServices = [{ id: '1', name: 'Standard Klipp' }]; | ||
(mockServiceRepository.save as jest.Mock).mockResolvedValue(mockServices); | ||
|
||
// Mock created employee user | ||
const mockEmployeeUser = { | ||
id: 'user-1', | ||
email: '[email protected]', | ||
role: UserRole.EMPLOYEE, | ||
}; | ||
(mockUserRepository.save as jest.Mock).mockResolvedValue(mockEmployeeUser); | ||
|
||
// Mock created employee | ||
const mockEmployee = { | ||
id: 'employee-1', | ||
user: mockEmployeeUser, | ||
}; | ||
(mockEmployeeRepository.save as jest.Mock).mockResolvedValue(mockEmployee); | ||
|
||
await createInitialData(mockDataSource as DataSource); | ||
|
||
// Verify employee user was created with default phone number | ||
expect(mockUserRepository.save).toHaveBeenCalledWith(expect.objectContaining({ | ||
phoneNumber: '+1234567890', // This is the default value | ||
})); | ||
}); | ||
}); |