mirror of
https://github.com/unraid/api.git
synced 2025-12-31 13:39:52 -06:00
fix: test issues
This commit is contained in:
@@ -23,6 +23,7 @@ describe('AuthResolver', () => {
|
|||||||
description: 'Test API Key Description',
|
description: 'Test API Key Description',
|
||||||
roles: [Role.GUEST],
|
roles: [Role.GUEST],
|
||||||
createdAt: new Date().toISOString(),
|
createdAt: new Date().toISOString(),
|
||||||
|
permissions: []
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockApiKeyWithSecret: ApiKeyWithSecret = {
|
const mockApiKeyWithSecret: ApiKeyWithSecret = {
|
||||||
@@ -32,6 +33,7 @@ describe('AuthResolver', () => {
|
|||||||
description: 'Test API Key Description',
|
description: 'Test API Key Description',
|
||||||
roles: [Role.GUEST],
|
roles: [Role.GUEST],
|
||||||
createdAt: new Date().toISOString(),
|
createdAt: new Date().toISOString(),
|
||||||
|
permissions: []
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
@@ -84,6 +86,7 @@ describe('AuthResolver', () => {
|
|||||||
name: 'New API Key',
|
name: 'New API Key',
|
||||||
description: 'New API Key Description',
|
description: 'New API Key Description',
|
||||||
roles: [Role.GUEST],
|
roles: [Role.GUEST],
|
||||||
|
permissions: []
|
||||||
};
|
};
|
||||||
|
|
||||||
vi.spyOn(apiKeyService, 'create').mockResolvedValue(mockApiKeyWithSecret);
|
vi.spyOn(apiKeyService, 'create').mockResolvedValue(mockApiKeyWithSecret);
|
||||||
@@ -92,11 +95,12 @@ describe('AuthResolver', () => {
|
|||||||
const result = await resolver.createApiKey(input);
|
const result = await resolver.createApiKey(input);
|
||||||
|
|
||||||
expect(result).toEqual(mockApiKeyWithSecret);
|
expect(result).toEqual(mockApiKeyWithSecret);
|
||||||
expect(apiKeyService.create).toHaveBeenCalledWith(
|
expect(apiKeyService.create).toHaveBeenCalledWith({
|
||||||
input.name,
|
name: input.name,
|
||||||
input.description,
|
description: input.description,
|
||||||
input.roles
|
roles: input.roles,
|
||||||
);
|
permissions: [],
|
||||||
|
});
|
||||||
expect(authService.syncApiKeyRoles).toHaveBeenCalledWith(mockApiKey.id, mockApiKey.roles);
|
expect(authService.syncApiKeyRoles).toHaveBeenCalledWith(mockApiKey.id, mockApiKey.roles);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user