mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-12-14 02:02:50 +00:00
22 lines
658 B
TypeScript
22 lines
658 B
TypeScript
// @vitest-environment nuxt
|
|
import { describe, expect, test } from 'vitest';
|
|
import { useRefreshableState } from './useRefreshableState';
|
|
|
|
describe('useRefreshableState composables', () => {
|
|
describe('useRefreshableState', () => {
|
|
test('the tuple provided by useRefreshableState contain the state that is the result of the provided function and a refresh function', () => {
|
|
let index = 0;
|
|
|
|
const [state, refresh] = useRefreshableState('key', () => ++index);
|
|
|
|
expect(state.value).to.equal(1);
|
|
expect(index).to.equal(1);
|
|
|
|
refresh();
|
|
|
|
expect(state.value).to.equal(2);
|
|
expect(index).to.equal(2);
|
|
});
|
|
});
|
|
});
|