test(users): update unit tests for GDPR consent and export functionality
This commit is contained in:
parent
ea6684b7fa
commit
818a92f18c
@ -212,24 +212,27 @@ describe('UsersService', () => {
|
|||||||
describe('updateGdprConsent', () => {
|
describe('updateGdprConsent', () => {
|
||||||
it('should update GDPR consent timestamp', async () => {
|
it('should update GDPR consent timestamp', async () => {
|
||||||
const id = 'user1';
|
const id = 'user1';
|
||||||
|
|
||||||
// Mock the update method
|
// Mock the update method
|
||||||
jest.spyOn(service, 'update').mockResolvedValueOnce(mockUser);
|
jest.spyOn(service, 'update').mockResolvedValueOnce(mockUser);
|
||||||
|
|
||||||
const result = await service.updateGdprConsent(id);
|
const result = await service.updateGdprConsent(id);
|
||||||
|
|
||||||
expect(service.update).toHaveBeenCalledWith(id, { gdprTimestamp: expect.any(Date) });
|
expect(service.update).toHaveBeenCalledWith(id, { gdprTimestamp: expect.any(Date) });
|
||||||
expect(result).toEqual(mockUser);
|
expect(result).toEqual({
|
||||||
|
...mockUser,
|
||||||
|
gdprConsentDate: mockUser.gdprTimestamp
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('exportUserData', () => {
|
describe('exportUserData', () => {
|
||||||
it('should export user data', async () => {
|
it('should export user data', async () => {
|
||||||
const id = 'user1';
|
const id = 'user1';
|
||||||
|
|
||||||
// Mock the findById method
|
// Mock the findById method
|
||||||
jest.spyOn(service, 'findById').mockResolvedValueOnce(mockUser);
|
jest.spyOn(service, 'findById').mockResolvedValueOnce(mockUser);
|
||||||
|
|
||||||
// Mock the database query for projects
|
// Mock the database query for projects
|
||||||
mockDb.select.mockImplementationOnce(() => mockDbOperations);
|
mockDb.select.mockImplementationOnce(() => mockDbOperations);
|
||||||
mockDbOperations.from.mockImplementationOnce(() => mockDbOperations);
|
mockDbOperations.from.mockImplementationOnce(() => mockDbOperations);
|
||||||
@ -244,7 +247,9 @@ describe('UsersService', () => {
|
|||||||
expect(result).toEqual({
|
expect(result).toEqual({
|
||||||
user: mockUser,
|
user: mockUser,
|
||||||
projects: [mockProject],
|
projects: [mockProject],
|
||||||
|
groups: [],
|
||||||
|
persons: []
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user