|
|
@ -3,6 +3,7 @@ import '../helpers.js'; // for the matchMedia polyfill
|
|
|
|
import { describe, it, assert } from 'vitest';
|
|
|
|
import { describe, it, assert } from 'vitest';
|
|
|
|
import { get } from 'svelte/store';
|
|
|
|
import { get } from 'svelte/store';
|
|
|
|
import { spring, tweened, Tween } from 'svelte/motion';
|
|
|
|
import { spring, tweened, Tween } from 'svelte/motion';
|
|
|
|
|
|
|
|
import { raf } from '../animation-helpers.js';
|
|
|
|
|
|
|
|
|
|
|
|
describe('motion', () => {
|
|
|
|
describe('motion', () => {
|
|
|
|
describe('spring', () => {
|
|
|
|
describe('spring', () => {
|
|
|
@ -38,6 +39,16 @@ describe('motion', () => {
|
|
|
|
size.update((v) => v + 10);
|
|
|
|
size.update((v) => v + 10);
|
|
|
|
assert.equal(get(size), 20);
|
|
|
|
assert.equal(get(size), 20);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('updates non-numeric values immediately', () => {
|
|
|
|
|
|
|
|
raf.reset();
|
|
|
|
|
|
|
|
const boolean = tweened(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean.set(true, { duration: 100 });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
raf.tick(1);
|
|
|
|
|
|
|
|
assert.equal(get(boolean), true);
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('Tween', () => {
|
|
|
|
describe('Tween', () => {
|
|
|
@ -47,6 +58,16 @@ describe('motion', () => {
|
|
|
|
size.set(100, { duration: 0 });
|
|
|
|
size.set(100, { duration: 0 });
|
|
|
|
assert.equal(size.current, 100);
|
|
|
|
assert.equal(size.current, 100);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('updates non-numeric values immediately', () => {
|
|
|
|
|
|
|
|
raf.reset();
|
|
|
|
|
|
|
|
const boolean = new Tween(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean.set(true, { duration: 100 });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
raf.tick(1);
|
|
|
|
|
|
|
|
assert.equal(boolean.current, true);
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('updates correctly when initialized with a `null`-ish value', () => {
|
|
|
|
it('updates correctly when initialized with a `null`-ish value', () => {
|
|
|
|