MCPcopy
hub / github.com/pmndrs/react-spring / describeGlobals

Function describeGlobals

packages/core/src/SpringValue.test.ts:1193–1260  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1191}
1192
1193function describeGlobals() {
1194 const defaults = { ...Globals }
1195 const resetGlobals = () => Globals.assign(defaults)
1196 describe('"skipAnimation" global', () => {
1197 afterEach(resetGlobals)
1198
1199 it('should skip animations', async () => {
1200 const spring = new SpringValue(0)
1201
1202 global.mockRaf.step()
1203
1204 spring.start(1)
1205
1206 expect(spring.get()).toEqual(0)
1207
1208 await global.advanceUntilIdle()
1209
1210 expect(spring.get()).toEqual(1)
1211
1212 Globals.assign({
1213 skipAnimation: true,
1214 })
1215
1216 spring.start(0)
1217
1218 expect(spring.get()).toEqual(0)
1219 })
1220
1221 it('should skip to end even if delay is present', async () => {
1222 const spring = new SpringValue(0)
1223
1224 global.mockRaf.step()
1225
1226 spring.start(1, { delay: 400 })
1227
1228 expect(spring.get()).toEqual(0)
1229
1230 await global.advanceUntilIdle()
1231
1232 expect(spring.get()).toEqual(1)
1233
1234 Globals.assign({
1235 skipAnimation: true,
1236 })
1237
1238 spring.start(0, {
1239 delay: 400,
1240 })
1241
1242 expect(spring.get()).toEqual(0)
1243 })
1244
1245 it('still calls "onStart", "onChange", and "onRest" props', async () => {
1246 const spring = new SpringValue(0)
1247
1248 const onStart = vi.fn()
1249 const onChange = vi.fn()
1250 const onRest = vi.fn()

Callers 1

Calls 3

startMethod · 0.95
stepMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…