@hedhog/admin 0.0.39 → 0.0.40
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.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,EAAE;QACpB,MAAM,MAAM,GAAkB,MAAM,cAAI,CAAC,mBAAmB,CAAC;YAC3D,SAAS,EAAE;gBACT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AAU,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,2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,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/locale/locale.service.spec.ts"],"names":[],"mappings":";;AAAA,6CAAsD;AACtD,qDAAiD;AACjD,2CAA+C;AAC/C,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AAE,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC;YACpE,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;QACtB,EAAE,CAAC,yDAAyD,EAAE,KAAK,IAAI,EAAE;YACvE,MAAM,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CACzD,4BAAmB,CACpB,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,8BAA8B,EAAE,KAAK,IAAI,EAAE;YAC5C,MAAM,aAAa,GAAc,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;YACpD,IAAI;iBACD,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,YAAY,CAAC;iBAC1C,iBAAiB,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;YAEnC,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;YACnD,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"menu.service.spec.d.ts","sourceRoot":"","sources":["../../src/menu/menu.service.spec.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,196 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const testing_1 = require("@nestjs/testing");
|
4
|
+
const menu_service_1 = require("./menu.service");
|
5
|
+
const prisma_1 = require("@hedhog/prisma");
|
6
|
+
const pagination_1 = require("@hedhog/pagination");
|
7
|
+
const common_1 = require("@nestjs/common");
|
8
|
+
describe('MenuService', () => {
|
9
|
+
let menuService;
|
10
|
+
let prismaService;
|
11
|
+
let paginationService;
|
12
|
+
const mockPrismaService = {
|
13
|
+
menus: {
|
14
|
+
create: jest.fn(),
|
15
|
+
update: jest.fn(),
|
16
|
+
deleteMany: jest.fn(),
|
17
|
+
findUnique: jest.fn(),
|
18
|
+
findMany: jest.fn(),
|
19
|
+
count: jest.fn(),
|
20
|
+
},
|
21
|
+
role_menus: {
|
22
|
+
deleteMany: jest.fn(),
|
23
|
+
createMany: jest.fn(),
|
24
|
+
},
|
25
|
+
menu_screens: {
|
26
|
+
deleteMany: jest.fn(),
|
27
|
+
createMany: jest.fn(),
|
28
|
+
},
|
29
|
+
};
|
30
|
+
const mockPaginationService = {
|
31
|
+
paginate: jest.fn(),
|
32
|
+
createInsensitiveSearch: jest.fn(),
|
33
|
+
};
|
34
|
+
beforeEach(async () => {
|
35
|
+
const module = await testing_1.Test.createTestingModule({
|
36
|
+
providers: [
|
37
|
+
menu_service_1.MenuService,
|
38
|
+
{ provide: prisma_1.PrismaService, useValue: mockPrismaService },
|
39
|
+
{ provide: pagination_1.PaginationService, useValue: mockPaginationService },
|
40
|
+
],
|
41
|
+
}).compile();
|
42
|
+
menuService = module.get(menu_service_1.MenuService);
|
43
|
+
prismaService = module.get(prisma_1.PrismaService);
|
44
|
+
paginationService = module.get(pagination_1.PaginationService);
|
45
|
+
});
|
46
|
+
afterEach(() => {
|
47
|
+
jest.clearAllMocks();
|
48
|
+
});
|
49
|
+
describe('create', () => {
|
50
|
+
it('should create a new menu', async () => {
|
51
|
+
const createMenuDto = {
|
52
|
+
name: 'Test Menu',
|
53
|
+
url: '/test',
|
54
|
+
icon: 'test-icon',
|
55
|
+
order: 1,
|
56
|
+
menu_id: undefined,
|
57
|
+
};
|
58
|
+
mockPrismaService.menus.create.mockResolvedValue(createMenuDto);
|
59
|
+
const result = await menuService.create(createMenuDto);
|
60
|
+
expect(result).toEqual(createMenuDto);
|
61
|
+
expect(prismaService.menus.create).toHaveBeenCalledWith({
|
62
|
+
data: createMenuDto,
|
63
|
+
});
|
64
|
+
});
|
65
|
+
});
|
66
|
+
describe('update', () => {
|
67
|
+
it('should update a menu', async () => {
|
68
|
+
const updateDto = { id: 1, data: { name: 'Updated Menu' } };
|
69
|
+
mockPrismaService.menus.update.mockResolvedValue(updateDto.data);
|
70
|
+
const result = await menuService.update(updateDto);
|
71
|
+
expect(result).toEqual(updateDto.data);
|
72
|
+
expect(prismaService.menus.update).toHaveBeenCalledWith({
|
73
|
+
where: { id: updateDto.id },
|
74
|
+
data: updateDto.data,
|
75
|
+
});
|
76
|
+
});
|
77
|
+
});
|
78
|
+
describe('delete', () => {
|
79
|
+
it('should delete menus', async () => {
|
80
|
+
const deleteDto = { ids: [1, 2, 3] };
|
81
|
+
mockPrismaService.menus.deleteMany.mockResolvedValue({ count: 3 });
|
82
|
+
const result = await menuService.delete(deleteDto);
|
83
|
+
expect(result).toEqual({ count: 3 });
|
84
|
+
expect(prismaService.menus.deleteMany).toHaveBeenCalledWith({
|
85
|
+
where: { id: { in: deleteDto.ids } },
|
86
|
+
});
|
87
|
+
});
|
88
|
+
it('should throw BadRequestException if no ids are provided', async () => {
|
89
|
+
await expect(menuService.delete({ ids: null })).rejects.toThrow(common_1.BadRequestException);
|
90
|
+
});
|
91
|
+
});
|
92
|
+
describe('listScreens', () => {
|
93
|
+
it('should paginate screens', async () => {
|
94
|
+
const locale = 'en';
|
95
|
+
const menuId = 1;
|
96
|
+
const paginationParams = {
|
97
|
+
page: 1,
|
98
|
+
pageSize: 10,
|
99
|
+
search: '',
|
100
|
+
sortField: '',
|
101
|
+
sortOrder: pagination_1.PageOrderDirection.Asc,
|
102
|
+
fields: '',
|
103
|
+
};
|
104
|
+
const mockScreens = [{ id: 1, name: 'Screen 1' }];
|
105
|
+
mockPaginationService.paginate.mockResolvedValue(mockScreens);
|
106
|
+
const result = await menuService.listScreens(locale, menuId, paginationParams);
|
107
|
+
expect(result).toEqual(mockScreens);
|
108
|
+
expect(paginationService.paginate).toHaveBeenCalledWith(prismaService.screens, paginationParams, expect.anything(), 'screen_translations');
|
109
|
+
});
|
110
|
+
});
|
111
|
+
describe('updateScreens', () => {
|
112
|
+
it('should update screens associated with a menu', async () => {
|
113
|
+
const menuId = 1;
|
114
|
+
const updateData = { ids: [1, 2, 3] };
|
115
|
+
jest
|
116
|
+
.spyOn(prismaService.menu_screens, 'deleteMany')
|
117
|
+
.mockResolvedValue(null);
|
118
|
+
jest
|
119
|
+
.spyOn(prismaService.menu_screens, 'createMany')
|
120
|
+
.mockResolvedValue(null);
|
121
|
+
await menuService.updateScreens(menuId, updateData);
|
122
|
+
expect(prismaService.menu_screens.deleteMany).toHaveBeenCalledWith({
|
123
|
+
where: { menu_id: menuId },
|
124
|
+
});
|
125
|
+
expect(prismaService.menu_screens.createMany).toHaveBeenCalledWith({
|
126
|
+
data: updateData.ids.map((screenId) => ({
|
127
|
+
menu_id: menuId,
|
128
|
+
screen_id: screenId,
|
129
|
+
})),
|
130
|
+
skipDuplicates: true,
|
131
|
+
});
|
132
|
+
});
|
133
|
+
});
|
134
|
+
describe('updateRoles', () => {
|
135
|
+
it('should update roles associated with a menu', async () => {
|
136
|
+
const menuId = 1;
|
137
|
+
const updateData = { ids: [1, 2] };
|
138
|
+
jest
|
139
|
+
.spyOn(prismaService.role_menus, 'deleteMany')
|
140
|
+
.mockResolvedValue(null);
|
141
|
+
jest
|
142
|
+
.spyOn(prismaService.role_menus, 'createMany')
|
143
|
+
.mockResolvedValue(null);
|
144
|
+
await menuService.updateRoles(menuId, updateData);
|
145
|
+
expect(prismaService.role_menus.deleteMany).toHaveBeenCalledWith({
|
146
|
+
where: { menu_id: menuId },
|
147
|
+
});
|
148
|
+
expect(prismaService.role_menus.createMany).toHaveBeenCalledWith({
|
149
|
+
data: updateData.ids.map((roleId) => ({
|
150
|
+
menu_id: menuId,
|
151
|
+
role_id: roleId,
|
152
|
+
})),
|
153
|
+
skipDuplicates: true,
|
154
|
+
});
|
155
|
+
});
|
156
|
+
});
|
157
|
+
describe('updateOrder', () => {
|
158
|
+
it('should update the order of menus', async () => {
|
159
|
+
const orderData = { ids: [1, 2, 3] };
|
160
|
+
jest.spyOn(prismaService.menus, 'count').mockResolvedValue(3);
|
161
|
+
jest.spyOn(prismaService.menus, 'update').mockResolvedValue(null);
|
162
|
+
await menuService.updateOrder(orderData);
|
163
|
+
expect(prismaService.menus.count).toHaveBeenCalledWith({
|
164
|
+
where: { id: { in: orderData.ids } },
|
165
|
+
});
|
166
|
+
expect(prismaService.menus.update).toHaveBeenCalledTimes(orderData.ids.length);
|
167
|
+
orderData.ids.forEach((id, index) => {
|
168
|
+
expect(prismaService.menus.update).toHaveBeenCalledWith({
|
169
|
+
where: { id },
|
170
|
+
data: { order: index + 1 },
|
171
|
+
});
|
172
|
+
});
|
173
|
+
});
|
174
|
+
it('should throw BadRequestException if IDs are invalid', async () => {
|
175
|
+
const orderData = { ids: [1, 2, 3] };
|
176
|
+
jest.spyOn(prismaService.menus, 'count').mockResolvedValue(2); // IDs não batem com o número esperado
|
177
|
+
await expect(menuService.updateOrder(orderData)).rejects.toThrow(common_1.BadRequestException);
|
178
|
+
});
|
179
|
+
});
|
180
|
+
/*
|
181
|
+
describe('getMenus', () => {
|
182
|
+
it('should get menus for a user', async () => {
|
183
|
+
const locale = 'en';
|
184
|
+
const userId = 1;
|
185
|
+
const mockMenus = [{ id: 1, name: 'Menu 1' }];
|
186
|
+
mockPrismaService.menus.findMany.mockResolvedValue(mockMenus);
|
187
|
+
|
188
|
+
const result = await menuService.getMenus(locale, userId);
|
189
|
+
|
190
|
+
expect(result).toEqual(mockMenus);
|
191
|
+
expect(prismaService.menus.findMany).toHaveBeenCalled();
|
192
|
+
});
|
193
|
+
});
|
194
|
+
*/
|
195
|
+
});
|
196
|
+
//# sourceMappingURL=menu.service.spec.js.map
|
@@ -0,0 +1 @@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