Переглянути джерело

♻️ refactor(role): rename checkPermission to hasPermission in tests

- 更新单元测试中对checkPermission方法的调用为hasPermission
- 更新集成测试中对checkPermission方法的调用为hasPermission
- 重命名单元测试中checkPermission测试套件为hasPermission
yourname 1 місяць тому
батько
коміт
64a9d3502a

+ 5 - 5
packages/user-module/tests/integration/role.integration.test.ts

@@ -158,16 +158,16 @@ describe('Role Integration Tests', () => {
       const role = await roleService.create(roleData);
 
       // Check existing permissions
-      expect(await roleService.checkPermission(role.id, 'user:create')).toBe(true);
-      expect(await roleService.checkPermission(role.id, 'user:read')).toBe(true);
-      expect(await roleService.checkPermission(role.id, 'user:update')).toBe(true);
+      expect(await roleService.hasPermission(role.id, 'user:create')).toBe(true);
+      expect(await roleService.hasPermission(role.id, 'user:read')).toBe(true);
+      expect(await roleService.hasPermission(role.id, 'user:update')).toBe(true);
 
       // Check non-existing permission
-      expect(await roleService.checkPermission(role.id, 'user:delete')).toBe(false);
+      expect(await roleService.hasPermission(role.id, 'user:delete')).toBe(false);
     });
 
     it('should return false for non-existent role', async () => {
-      const hasPermission = await roleService.checkPermission(999, 'user:create');
+      const hasPermission = await roleService.hasPermission(999, 'user:create');
       expect(hasPermission).toBe(false);
     });
   });

+ 4 - 4
packages/user-module/tests/unit/role.service.test.ts

@@ -52,7 +52,7 @@ describe('RoleService', () => {
     });
   });
 
-  describe('checkPermission', () => {
+  describe('hasPermission', () => {
     it('should return true when role has permission', async () => {
       const mockRole = {
         id: 1,
@@ -62,7 +62,7 @@ describe('RoleService', () => {
 
       vi.mocked(mockRepository.findOne).mockResolvedValue(mockRole);
 
-      const result = await roleService.checkPermission(1, 'user:create');
+      const result = await roleService.hasPermission(1, 'user:create');
 
       expect(result).toBe(true);
     });
@@ -76,7 +76,7 @@ describe('RoleService', () => {
 
       vi.mocked(mockRepository.findOne).mockResolvedValue(mockRole);
 
-      const result = await roleService.checkPermission(1, 'user:update');
+      const result = await roleService.hasPermission(1, 'user:update');
 
       expect(result).toBe(false);
     });
@@ -84,7 +84,7 @@ describe('RoleService', () => {
     it('should return false when role not found', async () => {
       vi.mocked(mockRepository.findOne).mockResolvedValue(null);
 
-      const result = await roleService.checkPermission(999, 'user:create');
+      const result = await roleService.hasPermission(999, 'user:create');
 
       expect(result).toBe(false);
     });