proxy conf

This commit is contained in:
Bastian Wagner
2024-12-06 14:45:54 +01:00
parent a8f9f111d2
commit 82b02001e4
4 changed files with 75 additions and 4 deletions

View File

@@ -0,0 +1,50 @@
import { CreateUserDto } from "src/model/dto/create-user.dto";
import { User } from "src/model/entitites";
import { IUser } from "src/model/interface";
export class MockUserRepository {
user: User = {
firstName: null,
lastName: null,
id: 'mockId',
username: 'mockuser@test.de',
createdAt: undefined,
lastLogin: undefined,
external: {
externalId: 'externalid',
user: null,
accessToken: "",
refreshToken: ""
},
isActive: false,
role: null,
systems: []
}
findByUsername = jest.fn().mockImplementation((username: string) => {
return this.user;
})
createUser = jest.fn().mockImplementation((register: CreateUserDto) => {
const user: User = {
firstName: null,
lastName: null,
id: 'mockId',
username: register.username,
createdAt: undefined,
lastLogin: undefined,
external: {
externalId: register.externalId,
user: null,
accessToken: "",
refreshToken: ""
},
isActive: false,
role: null,
systems: []
}
return user;
})
}

View File

@@ -4,8 +4,9 @@ import { HttpService } from '@nestjs/axios';
import { UserRepository } from 'src/model/repositories';
import { ConfigService } from '@nestjs/config';
import { JwtService } from '@nestjs/jwt';
import { MockUserRepository } from '../../../mocks/repositories/user.repository.mock';
describe('AppService', () => {
describe('AuthService', () => {
let service: AuthService;
beforeEach(async () => {
@@ -24,10 +25,15 @@ describe('AppService', () => {
it('should be defined', () => {
expect(service).toBeDefined();
});
it('should store a user on creation', async () => {
const user = await service.register({externalId: '123', username: 'sc'});
expect(service['userRepo'].createUser).toHaveBeenCalled();
expect(user.external.externalId).toEqual('123');
expect(user.username).toEqual('sc');
})
});
class MockUserRepository {
}
class MockHttpService {}