Add tests for modules/auth and modules/command-menu (#3548)
Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com> Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Matheus <matheus_benini@hotmail.com>
This commit is contained in:
@ -0,0 +1,33 @@
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import { enableFetchMocks } from 'jest-fetch-mock';
|
||||
|
||||
import { renewToken } from '@/auth/services/AuthService';
|
||||
|
||||
enableFetchMocks();
|
||||
|
||||
const tokens = {
|
||||
accessToken: {
|
||||
token: 'accessToken',
|
||||
expiresAt: 'expiresAt',
|
||||
},
|
||||
refreshToken: {
|
||||
token: 'refreshToken',
|
||||
expiresAt: 'expiresAt',
|
||||
},
|
||||
};
|
||||
|
||||
describe('AuthService', () => {
|
||||
it('should renewToken', async () => {
|
||||
fetchMock.mockResponse(() =>
|
||||
Promise.resolve({
|
||||
body: JSON.stringify({
|
||||
data: { renewToken: { tokens } },
|
||||
}),
|
||||
}),
|
||||
);
|
||||
await act(async () => {
|
||||
const res = await renewToken('http://localhost:3000', tokens);
|
||||
expect(res).toEqual(tokens);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user