1+ import { expect , describe , it } from 'vitest' ;
12import { act , renderHook } from '@testing-library/react' ;
23import { 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} ) ;
0 commit comments