chore: migrate CLI to ESM and vitest (#6777)

* chore: migrate CLI to ESM and vitest

* fix lint

* update github workflow

* format
This commit is contained in:
Ben McCann
2024-01-30 15:23:33 -08:00
committed by GitHub
parent 1bfef200a5
commit 9c7dee8551
21 changed files with 2447 additions and 4743 deletions

View File

@ -12,28 +12,21 @@ import {
spyOnConsole,
} from '../../test/cli-test-utils';
const mockPingServer = jest.fn(() => Promise.resolve({ data: { res: 'pong' } }));
const mockUserInfo = jest.fn(() => Promise.resolve({ data: { email: 'admin@example.com' } }));
const mockPingServer = vi.fn(() => Promise.resolve({ data: { res: 'pong' } }));
const mockUserInfo = vi.fn(() => Promise.resolve({ data: { email: 'admin@example.com' } }));
jest.mock('@immich/sdk', () => {
return {
...jest.requireActual('@immich/sdk'),
UserApi: jest.fn().mockImplementation(() => {
return { getMyUserInfo: mockUserInfo };
}),
ServerInfoApi: jest.fn().mockImplementation(() => {
return { pingServer: mockPingServer };
}),
};
});
vi.mock('@immich/sdk', async () => ({
...(await vi.importActual('@immich/sdk')),
UserApi: vi.fn().mockImplementation(() => {
return { getMyUserInfo: mockUserInfo };
}),
ServerInfoApi: vi.fn().mockImplementation(() => {
return { pingServer: mockPingServer };
}),
}));
describe('SessionService', () => {
let sessionService: SessionService;
let consoleSpy: jest.SpyInstance;
beforeAll(() => {
consoleSpy = spyOnConsole();
});
beforeEach(() => {
deleteAuthFile();
@ -93,6 +86,8 @@ describe('SessionService', () => {
});
it('should delete auth file when logging out', async () => {
const consoleSpy = spyOnConsole();
await createTestAuthFile(
JSON.stringify({
apiKey: TEST_IMMICH_API_KEY,