@hedhog/admin 0.0.39 → 0.0.41
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/auth/auth.service.spec.d.ts +2 -0
- package/dist/auth/auth.service.spec.d.ts.map +1 -0
- package/dist/auth/auth.service.spec.js +163 -0
- package/dist/auth/auth.service.spec.js.map +1 -0
- package/dist/locale/locale.module.js +2 -2
- package/dist/locale/locale.module.js.map +1 -1
- package/dist/locale/locale.service.js +1 -1
- package/dist/locale/locale.service.js.map +1 -1
- package/dist/locale/locale.service.spec.d.ts +2 -0
- package/dist/locale/locale.service.spec.d.ts.map +1 -0
- package/dist/locale/locale.service.spec.js +171 -0
- package/dist/locale/locale.service.spec.js.map +1 -0
- package/dist/menu/menu.service.d.ts.map +1 -1
- package/dist/menu/menu.service.js +2 -0
- package/dist/menu/menu.service.js.map +1 -1
- package/dist/menu/menu.service.spec.d.ts +2 -0
- package/dist/menu/menu.service.spec.d.ts.map +1 -0
- package/dist/menu/menu.service.spec.js +196 -0
- package/dist/menu/menu.service.spec.js.map +1 -0
- package/dist/role/role.service.spec.d.ts +2 -0
- package/dist/role/role.service.spec.d.ts.map +1 -0
- package/dist/role/role.service.spec.js +343 -0
- package/dist/role/role.service.spec.js.map +1 -0
- package/dist/route/route.service.spec.d.ts +2 -0
- package/dist/route/route.service.spec.d.ts.map +1 -0
- package/dist/route/route.service.spec.js +235 -0
- package/dist/route/route.service.spec.js.map +1 -0
- package/dist/screen/screen.service.spec.d.ts +2 -0
- package/dist/screen/screen.service.spec.d.ts.map +1 -0
- package/dist/screen/screen.service.spec.js +242 -0
- package/dist/screen/screen.service.spec.js.map +1 -0
- package/dist/setting/settings.service.spec.d.ts +2 -0
- package/dist/setting/settings.service.spec.d.ts.map +1 -0
- package/dist/setting/settings.service.spec.js +147 -0
- package/dist/setting/settings.service.spec.js.map +1 -0
- package/dist/user/user.service.spec.d.ts +2 -0
- package/dist/user/user.service.spec.d.ts.map +1 -0
- package/dist/user/user.service.spec.js +239 -0
- package/dist/user/user.service.spec.js.map +1 -0
- package/package.json +1 -1
- package/src/migrations/migrate-02.ts +137 -137
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"auth.service.spec.d.ts","sourceRoot":"","sources":["../../src/auth/auth.service.spec.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,163 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const testing_1 = require("@nestjs/testing");
|
4
|
+
const auth_service_1 = require("./auth.service");
|
5
|
+
const prisma_1 = require("@hedhog/prisma");
|
6
|
+
const jwt_1 = require("@nestjs/jwt");
|
7
|
+
const mail_1 = require("@hedhog/mail");
|
8
|
+
const common_1 = require("@nestjs/common");
|
9
|
+
const bcrypt_1 = require("bcrypt");
|
10
|
+
jest.mock('bcrypt');
|
11
|
+
describe('AuthService', () => {
|
12
|
+
let authService;
|
13
|
+
let prismaService;
|
14
|
+
let jwtService;
|
15
|
+
let mailService;
|
16
|
+
beforeEach(async () => {
|
17
|
+
const module = await testing_1.Test.createTestingModule({
|
18
|
+
providers: [
|
19
|
+
auth_service_1.AuthService,
|
20
|
+
{
|
21
|
+
provide: prisma_1.PrismaService,
|
22
|
+
useValue: {
|
23
|
+
users: {
|
24
|
+
findFirst: jest.fn(),
|
25
|
+
update: jest.fn(),
|
26
|
+
findUnique: jest.fn(),
|
27
|
+
},
|
28
|
+
},
|
29
|
+
},
|
30
|
+
{
|
31
|
+
provide: jwt_1.JwtService,
|
32
|
+
useValue: {
|
33
|
+
sign: jest.fn(),
|
34
|
+
verifyAsync: jest.fn(),
|
35
|
+
decode: jest.fn(),
|
36
|
+
},
|
37
|
+
},
|
38
|
+
{
|
39
|
+
provide: mail_1.MailService,
|
40
|
+
useValue: {
|
41
|
+
send: jest.fn(),
|
42
|
+
},
|
43
|
+
},
|
44
|
+
],
|
45
|
+
}).compile();
|
46
|
+
authService = module.get(auth_service_1.AuthService);
|
47
|
+
prismaService = module.get(prisma_1.PrismaService);
|
48
|
+
jwtService = module.get(jwt_1.JwtService);
|
49
|
+
mailService = module.get(mail_1.MailService);
|
50
|
+
});
|
51
|
+
it('should be defined', () => {
|
52
|
+
expect(authService).toBeDefined();
|
53
|
+
});
|
54
|
+
describe('loginWithEmailAndPassword', () => {
|
55
|
+
it('should throw NotFoundException if user is not found', async () => {
|
56
|
+
jest.spyOn(prismaService.users, 'findFirst').mockResolvedValue(null);
|
57
|
+
await expect(authService.loginWithEmailAndPassword('test@example.com', 'password')).rejects.toThrow(common_1.NotFoundException);
|
58
|
+
});
|
59
|
+
it('should throw NotFoundException if password is invalid', async () => {
|
60
|
+
const mockUser = {
|
61
|
+
id: 1,
|
62
|
+
name: 'Test User',
|
63
|
+
email: 'test@example.com',
|
64
|
+
password: 'hashedpassword',
|
65
|
+
multifactor_id: null,
|
66
|
+
code: null,
|
67
|
+
created_at: new Date(),
|
68
|
+
updated_at: new Date(),
|
69
|
+
};
|
70
|
+
jest.spyOn(prismaService.users, 'findFirst').mockResolvedValue(mockUser);
|
71
|
+
bcrypt_1.compare.mockResolvedValue(false);
|
72
|
+
await expect(authService.loginWithEmailAndPassword('test@example.com', 'password')).rejects.toThrow(common_1.NotFoundException);
|
73
|
+
});
|
74
|
+
it('should return a token if login is successful', async () => {
|
75
|
+
const mockUser = {
|
76
|
+
id: 1,
|
77
|
+
name: 'Test User',
|
78
|
+
email: 'test@example.com',
|
79
|
+
password: 'hashedpassword',
|
80
|
+
multifactor_id: null,
|
81
|
+
code: null,
|
82
|
+
created_at: new Date(),
|
83
|
+
updated_at: new Date(),
|
84
|
+
};
|
85
|
+
jest.spyOn(prismaService.users, 'findFirst').mockResolvedValue(mockUser);
|
86
|
+
bcrypt_1.compare.mockResolvedValue(true);
|
87
|
+
jest.spyOn(jwtService, 'sign').mockReturnValue('token');
|
88
|
+
const result = await authService.loginWithEmailAndPassword('test@example.com', 'password');
|
89
|
+
expect(result).toEqual({ token: 'token' });
|
90
|
+
});
|
91
|
+
});
|
92
|
+
describe('forget', () => {
|
93
|
+
it('should throw NotFoundException if user is not found', async () => {
|
94
|
+
jest.spyOn(prismaService.users, 'findFirst').mockResolvedValue(null);
|
95
|
+
await expect(authService.forget({ email: 'test@example.com' })).rejects.toThrow(common_1.NotFoundException);
|
96
|
+
});
|
97
|
+
it('should update user with reset code and send email', async () => {
|
98
|
+
const mockUser = {
|
99
|
+
id: 1,
|
100
|
+
name: 'Test User',
|
101
|
+
email: 'test@example.com',
|
102
|
+
password: 'hashedpassword',
|
103
|
+
multifactor_id: null,
|
104
|
+
code: null,
|
105
|
+
created_at: new Date(),
|
106
|
+
updated_at: new Date(),
|
107
|
+
};
|
108
|
+
jest.spyOn(prismaService.users, 'findFirst').mockResolvedValue(mockUser);
|
109
|
+
jest.spyOn(prismaService.users, 'update').mockResolvedValue(mockUser);
|
110
|
+
jest
|
111
|
+
.spyOn(authService, 'generateRandomString')
|
112
|
+
.mockReturnValue('resetCode');
|
113
|
+
const result = await authService.forget({ email: 'test@example.com' });
|
114
|
+
expect(prismaService.users.update).toHaveBeenCalledWith({
|
115
|
+
where: { id: 1 },
|
116
|
+
data: { code: 'resetCode' },
|
117
|
+
});
|
118
|
+
expect(mailService.send).toHaveBeenCalledWith({
|
119
|
+
to: 'test@example.com',
|
120
|
+
subject: 'Reset password',
|
121
|
+
body: `Reset your password by clicking <a href="${process.env.FRONTEND_URL}/reset-password/resetCode">here</a>`,
|
122
|
+
});
|
123
|
+
expect(result).toEqual(true);
|
124
|
+
});
|
125
|
+
});
|
126
|
+
describe('otp', () => {
|
127
|
+
it('should throw NotFoundException if user with code is not found', async () => {
|
128
|
+
jest.spyOn(jwtService, 'decode').mockReturnValue({ id: 1 });
|
129
|
+
jest.spyOn(prismaService.users, 'findFirst').mockResolvedValue(null);
|
130
|
+
await expect(authService.otp({ token: 'token', code: 123456 })).rejects.toThrow(common_1.NotFoundException);
|
131
|
+
});
|
132
|
+
it('should return a token if otp is valid', async () => {
|
133
|
+
const mockUser = {
|
134
|
+
id: 1,
|
135
|
+
name: 'Test User',
|
136
|
+
email: 'test@example.com',
|
137
|
+
password: 'hashedpassword',
|
138
|
+
multifactor_id: null,
|
139
|
+
code: null,
|
140
|
+
created_at: new Date(),
|
141
|
+
updated_at: new Date(),
|
142
|
+
};
|
143
|
+
jest.spyOn(jwtService, 'decode').mockReturnValue({ id: 1 });
|
144
|
+
jest.spyOn(prismaService.users, 'findFirst').mockResolvedValue(mockUser);
|
145
|
+
jest.spyOn(prismaService.users, 'update').mockResolvedValue(mockUser);
|
146
|
+
jest.spyOn(jwtService, 'sign').mockReturnValue('newToken');
|
147
|
+
const result = await authService.otp({ token: 'token', code: 123456 });
|
148
|
+
expect(prismaService.users.update).toHaveBeenCalledWith({
|
149
|
+
where: { id: 1 },
|
150
|
+
data: { code: null },
|
151
|
+
});
|
152
|
+
expect(result).toEqual({ token: 'newToken' });
|
153
|
+
});
|
154
|
+
});
|
155
|
+
describe('verifyToken', () => {
|
156
|
+
it('should verify and return token data', async () => {
|
157
|
+
jest.spyOn(jwtService, 'verifyAsync').mockResolvedValue({ id: 1 });
|
158
|
+
const result = await authService.verifyToken('token');
|
159
|
+
expect(result).toEqual({ id: 1 });
|
160
|
+
});
|
161
|
+
});
|
162
|
+
});
|
163
|
+
//# sourceMappingURL=auth.service.spec.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"auth.service.spec.js","sourceRoot":"","sources":["../../src/auth/auth.service.spec.ts"],"names":[],"mappings":";;AAAA,6CAAsD;AACtD,iDAA6C;AAC7C,2CAA+C;AAC/C,qCAAyC;AACzC,uCAA2C;AAC3C,2CAAmD;AACnD,mCAAiC;AAEjC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAEpB,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,IAAI,WAAwB,CAAC;IAC7B,IAAI,aAA4B,CAAC;IACjC,IAAI,UAAsB,CAAC;IAC3B,IAAI,WAAwB,CAAC;IAE7B,UAAU,CAAC,KAAK,IAAI,EAA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;QAC3B,EAAE,CAAC,qCAAqC,EAAE,KAAK,IAAI,EAAE;YACnD,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC,iBAAiB,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;YAEnE,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YAEtD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
@@ -13,7 +13,7 @@ const common_1 = require("@nestjs/common");
|
|
13
13
|
const locale_service_1 = require("./locale.service");
|
14
14
|
const locale_controller_1 = require("./locale.controller");
|
15
15
|
const locale_middleware_1 = require("./locale.middleware");
|
16
|
-
const
|
16
|
+
const auth_module_1 = require("../auth/auth.module");
|
17
17
|
let LocaleModule = class LocaleModule {
|
18
18
|
configure(consumer) {
|
19
19
|
consumer.apply(locale_middleware_1.LocaleMiddleware).forRoutes('*');
|
@@ -23,7 +23,7 @@ exports.LocaleModule = LocaleModule;
|
|
23
23
|
exports.LocaleModule = LocaleModule = __decorate([
|
24
24
|
(0, common_1.Module)({
|
25
25
|
imports: [
|
26
|
-
(0, common_1.forwardRef)(() =>
|
26
|
+
(0, common_1.forwardRef)(() => auth_module_1.AuthModule),
|
27
27
|
(0, common_1.forwardRef)(() => prisma_1.PrismaModule),
|
28
28
|
(0, common_1.forwardRef)(() => pagination_1.PaginationModule),
|
29
29
|
],
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"locale.module.js","sourceRoot":"","sources":["../../src/locale/locale.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,mDAAsD;AACtD,2CAA8C;AAC9C,2CAAwE;AACxE,qDAAiD;AACjD,2DAAuD;AACvD,2DAAuD;AACvD,
|
1
|
+
{"version":3,"file":"locale.module.js","sourceRoot":"","sources":["../../src/locale/locale.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,mDAAsD;AACtD,2CAA8C;AAC9C,2CAAwE;AACxE,qDAAiD;AACjD,2DAAuD;AACvD,2DAAuD;AACvD,qDAAiD;AAY1C,IAAM,YAAY,GAAlB,MAAM,YAAY;IACvB,SAAS,CAAC,QAA4B;QACpC,QAAQ,CAAC,KAAK,CAAC,oCAAgB,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAClD,CAAC;CACF,CAAA;AAJY,oCAAY;uBAAZ,YAAY;IAVxB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,wBAAU,CAAC;YAC5B,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,qBAAY,CAAC;YAC9B,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,6BAAgB,CAAC;SACnC;QACD,WAAW,EAAE,CAAC,oCAAgB,CAAC;QAC/B,SAAS,EAAE,CAAC,8BAAa,CAAC;QAC1B,OAAO,EAAE,CAAC,8BAAa,CAAC;KACzB,CAAC;GACW,YAAY,CAIxB"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"locale.service.js","sourceRoot":"","sources":["../../src/locale/locale.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mDAAsE;AACtE,2CAA+C;AAC/C,2CAKwB;AAMjB,IAAM,aAAa,GAAnB,MAAM,aAAa;IACxB,YAEmB,aAA4B,EAE5B,iBAAoC;QAFpC,kBAAa,GAAb,aAAa,CAAe;QAE5B,sBAAiB,GAAjB,iBAAiB,CAAmB;IACpD,CAAC;IAEJ,KAAK,CAAC,WAAW,CAAC,MAAc,EAAE,gBAA+B;QAC/D,MAAM,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAChC,MAAM,EAAE,GAAU,IAAI,CAAC,aAAa,CAAC,uBAAuB,CAC1D,MAAM,EACN,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ACvC,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAmC;QACxD,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC;YACvC,KAAK,EAAE,EAAE,EAAE,EAAE;YACb,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAE,GAAG,EAAa;QAC7B,IAAI,GAAG,IAAI,SAAS,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;YACpC,MAAM,IAAI,4BAAmB,CAC3B,8CAA8C,CAC/C,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,UAAU,CAAC;YAC3C,KAAK,EAAE;gBACL,EAAE,EAAE;oBACF,EAAE,EAAE,GAAG;iBACR;aACF;SACF,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAnLY,sCAAa;wBAAb,aAAa;IADzB,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,sBAAa,CAAC,CAAC,CAAA;IAEvC,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,8BAAiB,CAAC,CAAC,CAAA;qCADZ,sBAAa;QAET,8BAAiB;GAL5C,aAAa,CAmLzB"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"locale.service.spec.d.ts","sourceRoot":"","sources":["../../src/locale/locale.service.spec.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,171 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const testing_1 = require("@nestjs/testing");
|
4
|
+
const locale_service_1 = require("./locale.service");
|
5
|
+
const prisma_1 = require("@hedhog/prisma");
|
6
|
+
const pagination_1 = require("@hedhog/pagination");
|
7
|
+
const common_1 = require("@nestjs/common");
|
8
|
+
describe('LocaleService', () => {
|
9
|
+
let service;
|
10
|
+
let prismaService;
|
11
|
+
let paginationService;
|
12
|
+
beforeEach(async () => {
|
13
|
+
const module = await testing_1.Test.createTestingModule({
|
14
|
+
providers: [
|
15
|
+
locale_service_1.LocaleService,
|
16
|
+
{
|
17
|
+
provide: prisma_1.PrismaService,
|
18
|
+
useValue: {
|
19
|
+
translations: {
|
20
|
+
findMany: jest.fn(),
|
21
|
+
},
|
22
|
+
locales: {
|
23
|
+
findUnique: jest.fn(),
|
24
|
+
create: jest.fn(),
|
25
|
+
update: jest.fn(),
|
26
|
+
deleteMany: jest.fn(),
|
27
|
+
},
|
28
|
+
},
|
29
|
+
},
|
30
|
+
{
|
31
|
+
provide: pagination_1.PaginationService,
|
32
|
+
useValue: {
|
33
|
+
paginate: jest.fn(),
|
34
|
+
},
|
35
|
+
},
|
36
|
+
],
|
37
|
+
}).compile();
|
38
|
+
service = module.get(locale_service_1.LocaleService);
|
39
|
+
prismaService = module.get(prisma_1.PrismaService);
|
40
|
+
paginationService = module.get(pagination_1.PaginationService);
|
41
|
+
});
|
42
|
+
it('should be defined', () => {
|
43
|
+
expect(service).toBeDefined();
|
44
|
+
});
|
45
|
+
describe('getTranslations', () => {
|
46
|
+
it('should throw BadRequestException when localeCode is not provided', async () => {
|
47
|
+
await expect(service.getTranslations('', 'namespace')).rejects.toThrow(common_1.BadRequestException);
|
48
|
+
});
|
49
|
+
it('should return translations for a given localeCode and namespace', async () => {
|
50
|
+
const mockTranslations = [
|
51
|
+
{
|
52
|
+
id: 1,
|
53
|
+
locale_id: 1,
|
54
|
+
namespace_id: 1,
|
55
|
+
name: 'hello',
|
56
|
+
value: 'Hello',
|
57
|
+
created_at: new Date(),
|
58
|
+
updated_at: new Date(),
|
59
|
+
},
|
60
|
+
];
|
61
|
+
jest
|
62
|
+
.spyOn(prismaService.translations, 'findMany')
|
63
|
+
.mockResolvedValue(mockTranslations);
|
64
|
+
const result = await service.getTranslations('en-US', 'namespace');
|
65
|
+
expect(result).toEqual({ hello: 'Hello' });
|
66
|
+
});
|
67
|
+
});
|
68
|
+
describe('get', () => {
|
69
|
+
it('should paginate locales', async () => {
|
70
|
+
const mockPaginationResult = {
|
71
|
+
data: [],
|
72
|
+
total: 10,
|
73
|
+
lastPage: 1,
|
74
|
+
page: 1,
|
75
|
+
prev: 0,
|
76
|
+
next: 2,
|
77
|
+
pageSize: 10,
|
78
|
+
};
|
79
|
+
jest
|
80
|
+
.spyOn(paginationService, 'paginate')
|
81
|
+
.mockResolvedValue(mockPaginationResult);
|
82
|
+
const paginationParams = {
|
83
|
+
page: 1,
|
84
|
+
pageSize: 20,
|
85
|
+
sortField: '',
|
86
|
+
sortOrder: pagination_1.PageOrderDirection.Asc,
|
87
|
+
fields: '',
|
88
|
+
search: '',
|
89
|
+
};
|
90
|
+
const result = await service.get(paginationParams);
|
91
|
+
expect(paginationService.paginate).toHaveBeenCalledWith(prismaService.locales, paginationParams, expect.anything());
|
92
|
+
expect(result).toBe(mockPaginationResult);
|
93
|
+
});
|
94
|
+
});
|
95
|
+
describe('getById', () => {
|
96
|
+
it('should return a locale by ID', async () => {
|
97
|
+
const mockLocale = {
|
98
|
+
id: 1,
|
99
|
+
name: 'English',
|
100
|
+
code: 'en',
|
101
|
+
region: 'us',
|
102
|
+
country_id: 1,
|
103
|
+
created_at: new Date(),
|
104
|
+
updated_at: new Date(),
|
105
|
+
};
|
106
|
+
jest
|
107
|
+
.spyOn(prismaService.locales, 'findUnique')
|
108
|
+
.mockResolvedValue(mockLocale);
|
109
|
+
const result = await service.getById(1);
|
110
|
+
expect(result).toBe(mockLocale);
|
111
|
+
});
|
112
|
+
});
|
113
|
+
describe('create', () => {
|
114
|
+
it('should create a new locale', async () => {
|
115
|
+
const mockCreateDTO = {
|
116
|
+
name: 'English',
|
117
|
+
code: 'en',
|
118
|
+
region: 'us',
|
119
|
+
country_id: 1,
|
120
|
+
};
|
121
|
+
const mockLocale = {
|
122
|
+
id: 1,
|
123
|
+
name: 'English',
|
124
|
+
code: 'en',
|
125
|
+
region: 'us',
|
126
|
+
country_id: 1,
|
127
|
+
created_at: new Date(),
|
128
|
+
updated_at: new Date(),
|
129
|
+
};
|
130
|
+
jest.spyOn(prismaService.locales, 'create').mockResolvedValue(mockLocale);
|
131
|
+
const result = await service.create(mockCreateDTO);
|
132
|
+
expect(result).toBe(mockLocale);
|
133
|
+
});
|
134
|
+
});
|
135
|
+
describe('update', () => {
|
136
|
+
it('should update a locale', async () => {
|
137
|
+
const mockUpdateDTO = {
|
138
|
+
name: 'English Updated',
|
139
|
+
code: 'en',
|
140
|
+
region: 'us',
|
141
|
+
country_id: 1,
|
142
|
+
};
|
143
|
+
const mockLocale = {
|
144
|
+
id: 1,
|
145
|
+
name: 'English Updated',
|
146
|
+
code: 'en',
|
147
|
+
region: 'us',
|
148
|
+
country_id: 1,
|
149
|
+
created_at: new Date(),
|
150
|
+
updated_at: new Date(),
|
151
|
+
};
|
152
|
+
jest.spyOn(prismaService.locales, 'update').mockResolvedValue(mockLocale);
|
153
|
+
const result = await service.update({ id: 1, data: mockUpdateDTO });
|
154
|
+
expect(result).toBe(mockLocale);
|
155
|
+
});
|
156
|
+
});
|
157
|
+
describe('delete', () => {
|
158
|
+
it('should throw BadRequestException if no IDs are provided', async () => {
|
159
|
+
await expect(service.delete({ ids: null })).rejects.toThrow(common_1.BadRequestException);
|
160
|
+
});
|
161
|
+
it('should delete locales by IDs', async () => {
|
162
|
+
const mockDeleteDTO = { ids: [1, 2, 3] };
|
163
|
+
jest
|
164
|
+
.spyOn(prismaService.locales, 'deleteMany')
|
165
|
+
.mockResolvedValue({ count: 3 });
|
166
|
+
const result = await service.delete(mockDeleteDTO);
|
167
|
+
expect(result.count).toBe(3);
|
168
|
+
});
|
169
|
+
});
|
170
|
+
});
|
171
|
+
//# sourceMappingURL=locale.service.spec.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"locale.service.spec.js","sourceRoot":"","sources":["../../src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BAAuB,CAAC;AAGrD,qBACa,WAAW;IAGpB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAE9B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;gBAFjB,aAAa,EAAE,aAAa,EAE5B,iBAAiB,EAAE,iBAAiB;IAGjD,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY;IAehD,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY;IAe9C,WAAW,CACf,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,aAAa;IA+B3B,SAAS,CACb,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,aAAa;IAiC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,SAAI;IAkDnD,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAI5C,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,aAAa;IA+BvD,GAAG,CAAC,MAAM,EAAE,MAAM;IAMlB,MAAM,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS;IAMpD,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,SAAS,CAAA;KAAE;IAOpD,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,SAAS;IAgBzB,WAAW,CAAC,EAAE,GAAG,EAAE,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAsBpD"}
|
@@ -105,6 +105,7 @@ let MenuService = class MenuService {
|
|
105
105
|
if (menuId === 0) {
|
106
106
|
menuId = null;
|
107
107
|
}
|
108
|
+
console.log({ menuId, userId, locale });
|
108
109
|
let menus = (await this.prismaService.menus.findMany({
|
109
110
|
where: {
|
110
111
|
menu_id: menuId,
|
@@ -136,6 +137,7 @@ let MenuService = class MenuService {
|
|
136
137
|
},
|
137
138
|
},
|
138
139
|
}));
|
140
|
+
console.log({ menus });
|
139
141
|
menus = menus.map((m) => (0, utils_1.itemTranslations)('menu_translations', m));
|
140
142
|
for (let i = 0; i < menus.length; i++) {
|
141
143
|
menus[i].menus = await this.getMenus(locale, userId, menus[i].id);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"menu.service.js","sourceRoot":"","sources":["../../src/menu/menu.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mDAAsE;AACtE,2CAA+C;AAC/C,2CAKwB;AAMxB,yCAAiD;AAG1C,IAAM,WAAW,GAAjB,MAAM,WAAW;IACtB,YAEmB,aAA4B,EAE5B,iBAAoC;QAFpC,kBAAa,GAAb,aAAa,CAAe;QAE5B,sBAAiB,GAAjB,iBAAiB,CAAmB;IACpD,CAAC;IAEJ,KAAK,CAAC,aAAa,CAAC,MAAc,EAAE,IAAkB;QACpD,MAAM,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,UAAU,CAAC;YAC/C,KAAK,EAAE;gBACL,OAAO,EAAE,MAAM;aAChB;SACF,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,UAAU,CAAC;YAChD,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;gBAChC,OAAO,EAAE,MAAM;gBACf,SAAS,EAAE,QAAQ;aACpB,CAAC,CAAC;YACH,cAAc,EAAE,IAAI;SACrB,CAAC,CAAC;IACL,CAAC;IACD,KAAK,CAAC,WAAW,CAAC,MAAc,EAAE,IAAkB;QAClD,MAAM,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,UAAU,CAAC;YAC7C,KAAK,EAAE;gBACL,OAAO,EAAE,MAAM;aAChB;SACF,CAAC,CAAC;QAEH,OAAO,IAAI,C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