Update tests to use vi instead of jest

This commit is contained in:
Alejandro Celaya
2023-05-27 11:57:26 +02:00
parent e2cbb2713a
commit 07fcb4e016
117 changed files with 3699 additions and 325 deletions

View File

@@ -6,12 +6,12 @@ import { MAIN_COLOR } from '../../../src/utils/theme';
describe('ColorGenerator', () => {
let colorGenerator: ColorGenerator;
const storageMock = fromPartial<LocalStorage>({
set: jest.fn(),
get: jest.fn(),
set: vi.fn(),
get: vi.fn(),
});
beforeEach(() => {
jest.clearAllMocks();
vi.clearAllMocks();
colorGenerator = new ColorGenerator(storageMock);
});

View File

@@ -2,13 +2,13 @@ import { fromPartial } from '@total-typescript/shoehorn';
import { LocalStorage } from '../../../src/utils/services/LocalStorage';
describe('LocalStorage', () => {
const getItem = jest.fn((key) => (key === 'shlink.foo' ? JSON.stringify({ foo: 'bar' }) : null));
const setItem = jest.fn();
const getItem = vi.fn((key) => (key === 'shlink.foo' ? JSON.stringify({ foo: 'bar' }) : null));
const setItem = vi.fn();
const localStorageMock = fromPartial<Storage>({ getItem, setItem });
let storage: LocalStorage;
beforeEach(() => {
jest.clearAllMocks();
vi.clearAllMocks();
storage = new LocalStorage(localStorageMock);
});

View File

@@ -2,7 +2,7 @@ import { fromPartial } from '@total-typescript/shoehorn';
import type { ColorGenerator } from '../../../../src/utils/services/ColorGenerator';
export const colorGeneratorMock = fromPartial<ColorGenerator>({
getColorForKey: jest.fn(() => 'red'),
setColorForKey: jest.fn(),
isColorLightForKey: jest.fn(() => false),
getColorForKey: vi.fn(() => 'red'),
setColorForKey: vi.fn(),
isColorLightForKey: vi.fn(() => false),
});