Skip to content

Commit 640cacb

Browse files
committed
chore(test): fix test type
1 parent bf6fc28 commit 640cacb

File tree

4 files changed

+19
-17
lines changed

4 files changed

+19
-17
lines changed

test/base.test.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { expect, describe, it } from 'vitest';
12
import { act, renderHook } from '@testing-library/react';
23
import { useTravel } from '../src/index';
34

@@ -45,7 +46,7 @@ describe('useTravel', () => {
4546
{ count: 0 },
4647
{ count: 1 },
4748
{ count: 2 },
48-
{ count: 3 }
49+
{ count: 3 },
4950
]);
5051
});
5152

@@ -91,11 +92,7 @@ describe('useTravel', () => {
9192
[state, setState, controls] = result.current;
9293

9394
expect(controls.position).toBe(1);
94-
expect(controls.getHistory()).toEqual([
95-
{ count: 0 },
96-
{ count: 3 },
97-
]);
98-
95+
expect(controls.getHistory()).toEqual([{ count: 0 }, { count: 3 }]);
9996

10097
act(() => {
10198
setState((draft) => {
@@ -126,7 +123,7 @@ describe('useTravel', () => {
126123
expect(controls.getHistory()).toEqual([
127124
{ count: 0 },
128125
{ count: 3 },
129-
{ count: 6 }
126+
{ count: 6 },
130127
]);
131128
expect(controls.canArchive()).toBe(true);
132129
act(() => controls.archive());
@@ -137,7 +134,7 @@ describe('useTravel', () => {
137134
expect(controls.getHistory()).toEqual([
138135
{ count: 0 },
139136
{ count: 3 },
140-
{ count: 6 }
137+
{ count: 6 },
141138
]);
142139
expect(controls.canArchive()).toBe(false);
143140
});
@@ -162,7 +159,7 @@ describe('useTravel', () => {
162159
{ count: 0 },
163160
{ count: 1 },
164161
{ count: 2 },
165-
{ count: 3 }
162+
{ count: 3 },
166163
]);
167164

168165
// Go back to middle position
@@ -176,13 +173,13 @@ describe('useTravel', () => {
176173
setState({ count: 10 });
177174
setState({ count: 20 });
178175
});
179-
}).toThrow('setState cannot be called multiple times in the same render cycle.');
176+
}).toThrow(
177+
'setState cannot be called multiple times in the same render cycle.'
178+
);
180179
});
181180

182181
it('[useTravel]: Multiple rapid setState calls should each increment position correctly', () => {
183-
const { result } = renderHook(() =>
184-
useTravel(0, { autoArchive: true })
185-
);
182+
const { result } = renderHook(() => useTravel(0, { autoArchive: true }));
186183

187184
let [state, setState, controls] = result.current;
188185

@@ -191,6 +188,8 @@ describe('useTravel', () => {
191188
setState(1);
192189
setState(2);
193190
});
194-
}).toThrow('setState cannot be called multiple times in the same render cycle.');
191+
}).toThrow(
192+
'setState cannot be called multiple times in the same render cycle.'
193+
);
195194
});
196195
});

test/edge-cases.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { expect, describe, it } from 'vitest';
12
import { act, renderHook } from '@testing-library/react';
23
import { useTravel } from '../src/index';
34

@@ -508,4 +509,4 @@ describe('useTravel - Edge Cases', () => {
508509
expect(controls.position).toBe(1);
509510
});
510511
});
511-
});
512+
});

test/index.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { expect, describe, it } from 'vitest';
12
import { act, renderHook } from '@testing-library/react';
23
import { vi } from 'vitest';
34
import { useTravel } from '../src/index';

test/validation.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import { expect, describe, it, beforeEach, afterEach } from 'vitest';
12
import { renderHook } from '@testing-library/react';
23
import { vi } from 'vitest';
34
import { useTravel } from '../src/index';
45

56
// Mock __DEV__ flag to be true for these tests
6-
// @ts-expect-error - Mocking global variable
7+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
78
globalThis.__DEV__ = true;
89

910
describe('useTravel - Input Validation', () => {
@@ -274,4 +275,4 @@ describe('useTravel - Input Validation', () => {
274275
expect(consoleErrorSpy).not.toHaveBeenCalled();
275276
});
276277
});
277-
});
278+
});

0 commit comments

Comments
 (0)