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:
gitstart-twenty
2024-01-19 12:37:49 +01:00
committed by GitHub
parent c868347552
commit 1bb7ff3730
7 changed files with 663 additions and 0 deletions

View File

@ -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);
});
});
});