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

Function describeFromProp

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

Source from the content-addressed store, hash-verified

251}
252
253function describeFromProp() {
254 describe('when "from" prop is defined', () => {
255 it('controls the start value', async () => {
256 const spring = new SpringValue<number>()
257 const onChange = vi.fn()
258 spring.start({
259 from: 5,
260 to: 10,
261 config: { duration: 10 * frameLength },
262 onChange,
263 })
264 expect(spring.get()).toBe(5)
265 await global.advance()
266 // After the first frame the spring should have moved away from "from"
267 // toward "to" — it should never have read its prior current value.
268 // `onChange` receives an AnimationResult, so read `result.value`. See #2183.
269 expect(onChange.mock.calls[0][0].value).toBeGreaterThan(5)
270 await global.advanceUntilIdle()
271 expect(spring.get()).toBe(10)
272 })
273 })
274}
275
276function describeResetProp() {
277 describe('when "reset" prop is true', () => {

Callers 1

describePropsFunction · 0.85

Calls 3

startMethod · 0.95
getMethod · 0.65
advanceMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…