Skip to content

Commit 162b2be

Browse files
committed
test: animating between named colors with "loop"
1 parent 2f7c1ab commit 162b2be

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

packages/core/src/SpringValue.test.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,23 @@ function describeTarget(name: string, create: (from: number) => OpaqueTarget) {
509509
})
510510

511511
describe('when animating a string', () => {
512-
it.todo('animates as expected')
512+
it('animates as expected', async () => {
513+
const spring = new SpringValue('yellow')
514+
spring.start('red', {
515+
config: { duration: frameLength * 3 },
516+
})
517+
518+
await advanceUntilIdle()
519+
spring.start({
520+
loop: true,
521+
reverse: true,
522+
})
523+
524+
await advanceUntilValue(spring, 'yellow')
525+
await advanceUntilValue(spring, 'red')
526+
await advanceUntilValue(spring, 'yellow')
527+
expect(getFrames(spring)).toMatchSnapshot()
528+
})
513529
})
514530

515531
describe('when animating an array', () => {

packages/core/src/__snapshots__/SpringValue.test.ts.snap

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,3 +234,37 @@ Array [
234234
0.022634843307857987,
235235
]
236236
`;
237+
238+
exports[`SpringValue when our target is an Interpolation when animating a string animates as expected 1`] = `
239+
Array [
240+
"rgba(255, 170, 0, 1)",
241+
"rgba(255, 85, 0, 1)",
242+
"red",
243+
"rgba(255, 85, 0, 1)",
244+
"rgba(255, 170, 0, 1)",
245+
"yellow",
246+
"rgba(255, 170, 0, 1)",
247+
"rgba(255, 85, 0, 1)",
248+
"red",
249+
"rgba(255, 85, 0, 1)",
250+
"rgba(255, 170, 0, 1)",
251+
"yellow",
252+
]
253+
`;
254+
255+
exports[`SpringValue when our target is another SpringValue when animating a string animates as expected 1`] = `
256+
Array [
257+
"rgba(255, 170, 0, 1)",
258+
"rgba(255, 85, 0, 1)",
259+
"red",
260+
"rgba(255, 85, 0, 1)",
261+
"rgba(255, 170, 0, 1)",
262+
"yellow",
263+
"rgba(255, 170, 0, 1)",
264+
"rgba(255, 85, 0, 1)",
265+
"red",
266+
"rgba(255, 85, 0, 1)",
267+
"rgba(255, 170, 0, 1)",
268+
"yellow",
269+
]
270+
`;

0 commit comments

Comments
 (0)