forked from verdnatura/salix-front
32 lines
1005 B
JavaScript
32 lines
1005 B
JavaScript
import { vi, describe, expect, it } from 'vitest';
|
|
import { axios, flushPromises } from 'app/test/vitest/helper';
|
|
import { useTokenConfig } from 'composables/useTokenConfig';
|
|
const tokenConfig = useTokenConfig();
|
|
|
|
describe('useTokenConfig', () => {
|
|
describe('fetch', () => {
|
|
it('should call setTokenConfig of the state with the expected data', async () => {
|
|
const data = {
|
|
id: 1,
|
|
renewPeriod: 21600,
|
|
courtesyTime: 60,
|
|
renewInterval: 300,
|
|
};
|
|
vi.spyOn(axios, 'get').mockResolvedValueOnce({
|
|
data,
|
|
});
|
|
|
|
vi.spyOn(tokenConfig.state, 'setTokenConfig');
|
|
|
|
tokenConfig.fetch();
|
|
|
|
await flushPromises();
|
|
|
|
expect(tokenConfig.state.setTokenConfig).toHaveBeenCalledWith(data);
|
|
|
|
const renewPeriod = sessionStorage.getItem('renewPeriod');
|
|
expect(renewPeriod).toEqual(data.renewPeriod);
|
|
});
|
|
});
|
|
});
|