diff --git a/server/src/modules/auth/__test/auth.controller.spec.ts b/server/src/modules/auth/__test/auth.controller.spec.ts index eb7e0ca7..2aed3d04 100644 --- a/server/src/modules/auth/__test/auth.controller.spec.ts +++ b/server/src/modules/auth/__test/auth.controller.spec.ts @@ -92,7 +92,10 @@ describe('AuthController', () => { }; await expect(controller.register(mockUserInfo)).rejects.toThrow( - new HttpException('密码无效', EXCEPTION_CODE.PASSWORD_INVALID), + new HttpException( + '密码只能输入数字、字母、特殊字符', + EXCEPTION_CODE.PASSWORD_INVALID, + ), ); }); }); @@ -217,4 +220,29 @@ describe('AuthController', () => { expect(typeof result.data.img).toBe('string'); }); }); + + describe('password strength', () => { + it('it should return strong', async () => { + await expect( + controller.getPasswordStrength('abcd&1234'), + ).resolves.toEqual({ + code: 200, + data: 'Strong', + }); + }); + + it('it should return medium', async () => { + await expect(controller.getPasswordStrength('abc123')).resolves.toEqual({ + code: 200, + data: 'Medium', + }); + }); + + it('it should return weak', async () => { + await expect(controller.getPasswordStrength('123456')).resolves.toEqual({ + code: 200, + data: 'Weak', + }); + }); + }); }); diff --git a/server/src/modules/workspace/_test/workspace.controller.spec.ts b/server/src/modules/workspace/_test/workspace.controller.spec.ts index 73d84ab3..9431b6ce 100644 --- a/server/src/modules/workspace/_test/workspace.controller.spec.ts +++ b/server/src/modules/workspace/_test/workspace.controller.spec.ts @@ -245,8 +245,10 @@ describe('WorkspaceController', () => { const req = { user: { _id: new ObjectId() } }; const workspaceId = new ObjectId(); - const memberList = [{ workspaceId, userId: new ObjectId() }]; + const userId = new ObjectId(); + const memberList = [{ workspaceId, userId: userId }]; const workspaces = [{ _id: workspaceId, name: 'Test Workspace' }]; + const userList = [{ _id: userId, username: 'Test User' }]; jest .spyOn(workspaceService, 'findAllByUserId') @@ -254,6 +256,9 @@ describe('WorkspaceController', () => { jest .spyOn(workspaceMemberService, 'batchSearchByWorkspace') .mockResolvedValue(memberList as unknown as Array); + jest + .spyOn(userService, 'getUserListByIds') + .mockResolvedValue(userList as User[]); const result = await controller.getWorkspaceAndMember(req);