46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
// @ts-nocheck
|
|
import { Test, TestingModule } from '@nestjs/testing';
|
|
import { JwtService } from '@nestjs/jwt';
|
|
import { AuthService } from '../auth.service';
|
|
import { PrismaService } from '../../../prisma/prisma.service';
|
|
|
|
jest.mock('bcryptjs', () => ({
|
|
compare: jest.fn(),
|
|
hash: jest.fn(),
|
|
}));
|
|
|
|
describe('AuthService', () => {
|
|
let service: AuthService;
|
|
|
|
beforeEach(async () => {
|
|
const mockPrisma = {
|
|
user: {
|
|
create: jest.fn().mockResolvedValue({ id: 1 }),
|
|
findFirst: jest.fn().mockResolvedValue(null),
|
|
findUnique: jest.fn().mockResolvedValue(null),
|
|
update: jest.fn().mockResolvedValue({}),
|
|
},
|
|
};
|
|
|
|
const mockJwtService = {
|
|
sign: jest.fn().mockReturnValue('mock-token'),
|
|
verify: jest.fn().mockReturnValue({ sub: 1 }),
|
|
};
|
|
|
|
const module = await Test.createTestingModule({
|
|
providers: [
|
|
AuthService,
|
|
{ provide: PrismaService, useValue: mockPrisma },
|
|
{ provide: JwtService, useValue: mockJwtService },
|
|
],
|
|
}).compile();
|
|
|
|
service = module.get<AuthService>(AuthService);
|
|
jest.clearAllMocks();
|
|
});
|
|
|
|
it('should be defined', () => {
|
|
expect(service).toBeDefined();
|
|
});
|
|
});
|