2024-03-21 13:59:49 +02:00
|
|
|
import { ICryptoRepository } from 'src/interfaces/crypto.interface';
|
2024-04-16 16:44:45 +02:00
|
|
|
import { Mocked, vitest } from 'vitest';
|
2023-01-18 16:40:15 +02:00
|
|
|
|
2024-04-16 16:44:45 +02:00
|
|
|
export const newCryptoRepositoryMock = (): Mocked<ICryptoRepository> => {
|
2023-01-18 16:40:15 +02:00
|
|
|
return {
|
2024-04-16 16:44:45 +02:00
|
|
|
randomUUID: vitest.fn().mockReturnValue('random-uuid'),
|
|
|
|
randomBytes: vitest.fn().mockReturnValue(Buffer.from('random-bytes', 'utf8')),
|
|
|
|
compareBcrypt: vitest.fn().mockReturnValue(true),
|
|
|
|
hashBcrypt: vitest.fn().mockImplementation((input) => Promise.resolve(`${input} (hashed)`)),
|
|
|
|
hashSha256: vitest.fn().mockImplementation((input) => `${input} (hashed)`),
|
2024-07-01 19:43:16 +02:00
|
|
|
verifySha256: vitest.fn().mockImplementation(() => true),
|
2024-04-16 16:44:45 +02:00
|
|
|
hashSha1: vitest.fn().mockImplementation((input) => Buffer.from(`${input.toString()} (hashed)`)),
|
|
|
|
hashFile: vitest.fn().mockImplementation((input) => `${input} (file-hashed)`),
|
|
|
|
newPassword: vitest.fn().mockReturnValue(Buffer.from('random-bytes').toString('base64')),
|
2023-01-18 16:40:15 +02:00
|
|
|
};
|
|
|
|
};
|