Skip to content

Commit 6d59c9d

Browse files
committed
fix: faker update
1 parent 60d25b6 commit 6d59c9d

21 files changed

+32
-34
lines changed

.vscode/settings.json

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"adminjs",
44
"amqps",
55
"animes",
6+
"antfu",
67
"Basiq",
78
"Bhandari",
89
"casl",

src/_mocks_/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ export const mockRequest = createMock<NestifyRequest>({
121121
},
122122
});
123123

124-
125124
export const mockResponse = createMock<NestifyResponse>();
126125
export const mockAmqConnection = createMock<AmqpConnection>();
127126
export const mockCloudinaryService = createMock<CloudinaryService>();
@@ -159,13 +158,13 @@ mockUserRepo.softRemoveAndFlush.mockImplementation((entity) => {
159158
});
160159

161160
mockUserRepo.findOne.mockImplementation((options: FilterQuery<User>) => {
162-
if (options?.idx) {
161+
if ("idx" in options) {
163162
return Promise.resolve({
164163
user: mockedUser,
165164
idx: options.idx,
166165
} as any);
167166
}
168-
else if (options.username) {
167+
else if ("username" in options) {
169168
return Promise.resolve({
170169
...mockedUser,
171170
username: options.username,
@@ -200,6 +199,7 @@ mockPostRepo.softRemoveAndFlush.mockImplementation((entity) => {
200199
});
201200

202201
mockOtpLogRepo.findOne.mockImplementation(options =>
202+
203203
Promise.resolve({
204204
user: mockedUser,
205205
idx: options.idx,

src/common/@types/interfaces/crud.interface.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export interface Crud<
1515
Entity extends BaseEntity,
1616
PaginationRequest extends TPaginationRequest,
1717
CreateDto extends RequiredEntityData<Entity> = RequiredEntityData<Entity>,
18-
UpdateDto extends Partial<EntityDTO<FromEntityType<Entity>>> = Partial<EntityDTO<FromEntityType<Entity>>>,
18+
UpdateDto extends Partial<EntityDTO<FromEntityType<Entity>>> = Partial<EntityDTO<FromEntityType<Entity>>>,
1919
> {
2020
findAll(query: PaginationRequest): Observable<PaginationResponse<Entity>>
2121

src/common/@types/interfaces/pagination.interface.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type {Dictionary, QueryBuilder } from "@mikro-orm/postgresql";
1+
import type { Dictionary, QueryBuilder } from "@mikro-orm/postgresql";
22
import type { CursorPaginationDto, OffsetPaginationDto } from "@common/dtos";
33
import type { CursorPaginationResponse, OffsetPaginationResponse } from "../classes";
44
import { CursorType, QueryCursor, QueryOrder } from "../enums";

src/common/database/factories/conversation.factory.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { randMovie } from '@ngneat/falso';
1+
import { randMovie } from "@ngneat/falso";
22
import { Factory } from "@mikro-orm/seeder";
33
import { Conversation } from "@entities";
44

src/common/database/factories/message.factory.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { randProductDescription } from '@ngneat/falso';
1+
import { randProductDescription } from "@ngneat/falso";
22
import { Factory } from "@mikro-orm/seeder";
33
import { Message } from "@entities";
44

src/common/database/factories/protocol.factory.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import { Factory } from "@mikro-orm/seeder";
32
import { Protocol } from "@entities";
43

src/entities/post.entity.ts

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export class Post extends BaseEntity {
3939
@Property()
4040
readCount? = 0;
4141

42-
4342
@Property()
4443
published = false;
4544

src/lib/casl/generic.policy.ts

+2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ export class GenericPolicyHandler implements PoliciesHandler {
1515

1616
if ([Action.Create, Action.Read, Action.Delete].includes(this.action))
1717

18+
// eslint-disable-next-line ts/no-unsafe-argument
1819
return ability.can(this.action, this.ClassType);
1920

2021
const id = request.params.id;
2122

23+
// eslint-disable-next-line ts/no-unsafe-argument, ts/no-unsafe-call
2224
return ability.can(Action.Update, new this.ClassType({ id }));
2325
}
2426
}

src/lib/crud/crud.controller.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export function ControllerFactory<
5252
T extends BaseEntity,
5353
Q extends PaginationRequest,
5454
C extends RequiredEntityData<T>,
55-
U extends Partial<EntityDTO<FromEntityType<T>>>
55+
U extends Partial<EntityDTO<FromEntityType<T>>>,
5656
> implements Crud<T, Q, C, U> {
5757
protected service!: BaseService<T, Q, C, U>;
5858

src/lib/crud/crud.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export abstract class BaseService<
1212
Entity extends BaseEntity,
1313
PRequest extends PaginationRequest,
1414
CreateDto extends RequiredEntityData<Entity> = RequiredEntityData<Entity>,
15-
UpdateDto extends Partial<EntityDTO<FromEntityType<Entity>>> = Partial<EntityDTO<FromEntityType<Entity>>>,
15+
UpdateDto extends Partial<EntityDTO<FromEntityType<Entity>>> = Partial<EntityDTO<FromEntityType<Entity>>>,
1616
> implements Crud<Entity, PRequest> {
1717
protected searchField!: keyof Entity;
1818
protected queryName = "entity";

src/lib/orm.module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { baseOptions } from "@common/database/orm.config";
2121
}),
2222
}),
2323
MikroOrmModule.forFeature({
24-
entities: baseOptions.entities
24+
entities: baseOptions.entities,
2525
}),
2626
],
2727
exports: [MikroOrmModule],

src/modules/auth/strategies/google.strategy.ts

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { BaseRepository } from "@common/database";
1010
import type { OauthResponse } from "@common/@types";
1111
import { randAnimal, randCatchPhrase, randFirstName } from "@ngneat/falso";
1212

13-
1413
@Injectable()
1514
export class GoogleStrategy extends PassportStrategy(Strategy, "google") {
1615
/**

src/modules/chat/chat.service.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { InjectRepository } from "@mikro-orm/nestjs";
2-
import { EntityManager } from "@mikro-orm/postgresql";
2+
import { EntityManager, ref } from "@mikro-orm/postgresql";
33
import { Injectable } from "@nestjs/common";
4-
import { ref } from "@mikro-orm/postgresql";
54
import type { User } from "@entities";
65
import { Conversation, Message } from "@entities";
76
import { BaseRepository } from "@common/database";

src/modules/post/post.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export class PostService {
132132
switchMap((tags) => {
133133
this.postRepository.assign(post, {
134134
...omit(dto, ["tags", "categories"]),
135-
tags
135+
tags,
136136
});
137137

138138
return from(this.em.flush()).pipe(map(() => post));

src/modules/token/refresh-tokens.repository.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { EntityRepository } from "@mikro-orm/postgresql";
1+
import { EntityManager, EntityRepository } from "@mikro-orm/postgresql";
22
import { InjectRepository } from "@mikro-orm/nestjs";
3-
import { EntityManager } from "@mikro-orm/postgresql";
43
import { Injectable } from "@nestjs/common";
54
import type { Observable } from "rxjs";
65
import { from, map } from "rxjs";

src/socket-io.adapter.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class SocketIOAdapter extends IoAdapter {
4949
cors,
5050
};
5151

52-
const server: Server = super.createIOServer(port, optionsWithCORS);
52+
const server = super.createIOServer(port, optionsWithCORS) as Server;
5353

5454
server.adapter(this.adapterConstructor);
5555

test/e2e/user.e2e-spec.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import path from "node:path";
22

3-
import { faker } from "@mikro-orm/seeder";
43
import { pick } from "helper-fns";
54
import request from "supertest";
65
import type { OffsetPaginationResponse } from "@common/@types";
76
import { Roles } from "@common/@types";
7+
import { randEmail, randUserName } from "@ngneat/falso";
88
import type { SuperTestBody } from "../fixtures";
99
import { APP_URL, user, userDto } from "../fixtures";
1010

@@ -45,8 +45,8 @@ describe("UserController (e2e)", () => {
4545
});
4646

4747
it("should self register a new user /users/signup (POST)", () => {
48-
const email = faker.internet.email();
49-
const username = faker.internet.userName();
48+
const email = randEmail();
49+
const username = randUserName();
5050

5151
return request(app)
5252
.post("/users/signup")
@@ -65,7 +65,7 @@ describe("UserController (e2e)", () => {
6565
.post("/users/signup")
6666
.send({
6767
...pick(userDto, ["roles"]),
68-
email: faker.internet.email(),
68+
email: randEmail(),
6969
})
7070
.expect(({ body }: SuperTestBody) => {
7171
expect(body.errors).toStrictEqual(["property roles should not exist"]);

test/fixtures/constant.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { faker } from "@mikro-orm/seeder";
1+
import { randAbbreviation, randCatchPhrase } from "@ngneat/falso";
22

33
export const APP_URL = "http://localhost:8000/v1";
4-
export const name = faker.commerce.productName();
4+
export const name = randCatchPhrase() + randAbbreviation();

test/fixtures/post.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { faker } from "@mikro-orm/seeder";
1+
import { randAbbreviation, randBrand, randCatchPhrase } from "@ngneat/falso";
22

33
export const postDto = {
4-
title: faker.name.firstName(),
5-
description: faker.name.firstName(),
6-
content: faker.lorem.sentence(),
7-
tags: [faker.company.name(), faker.company.name()],
4+
title: randBrand(),
5+
description: randCatchPhrase(),
6+
content: randCatchPhrase(),
7+
tags: [randAbbreviation(), randAbbreviation()],
88
};
99

1010
export interface SuperTestBody<T = unknown> {

test/fixtures/user.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import process from "node:process";
2-
import { faker } from "@mikro-orm/seeder";
32
import { Roles } from "@common/@types";
3+
import { randEmail, randFirstName, randLastName } from "@ngneat/falso";
44

55
export const user: Record<string, { email: string, password: string }> = {
66
admin: {
@@ -18,9 +18,9 @@ export const user: Record<string, { email: string, password: string }> = {
1818
};
1919

2020
export const userDto = {
21-
firstName: faker.name.firstName(),
22-
lastName: faker.name.firstName(),
23-
email: faker.internet.email(),
21+
firstName: randFirstName(),
22+
lastName: randLastName(),
23+
email: randEmail(),
2424
username: "username",
2525
roles: [Roles.AUTHOR],
2626
password: process.env.USER_PASSWORD!,

0 commit comments

Comments
 (0)