|
|
|
@ -5,43 +5,62 @@ import { TransitionConfig } from 'svelte/transition';
|
|
|
|
declare const global: any;
|
|
|
|
declare const global: any;
|
|
|
|
|
|
|
|
|
|
|
|
describe('transitions', () => {
|
|
|
|
describe('transitions', () => {
|
|
|
|
let originalRequestAnimationFrame: () => void;
|
|
|
|
let originalRequestAnimationFrame: () => void;
|
|
|
|
|
|
|
|
|
|
|
|
before(() => {
|
|
|
|
before(() => {
|
|
|
|
originalRequestAnimationFrame = global.requestAnimationFrame;
|
|
|
|
originalRequestAnimationFrame = global.requestAnimationFrame;
|
|
|
|
global.requestAnimationFrame = cb => cb();
|
|
|
|
global.requestAnimationFrame = (cb) => cb();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
after(() => {
|
|
|
|
|
|
|
|
global.requestAnimationFrame = originalRequestAnimationFrame;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
after(() => {
|
|
|
|
beforeEach(() => {
|
|
|
|
global.requestAnimationFrame = originalRequestAnimationFrame;
|
|
|
|
group_outros();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
|
|
|
group_outros();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe('create_out_transition', () => {
|
|
|
|
describe('create_out_transition', () => {
|
|
|
|
describe('when then transition function returns undefined', () => {
|
|
|
|
describe('when then transition function does not return a tick function', () => {
|
|
|
|
describe('when calling the end function with reset param equals to true', () => {
|
|
|
|
describe('when calling the end function with reset param equals to true', () => {
|
|
|
|
it('should not throw an exception', () => {
|
|
|
|
it('should not throw an exception', () => {
|
|
|
|
|
|
|
|
const noTickConfigs: TransitionConfig[] = [undefined, null, {}];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
noTickConfigs.forEach((config) => {
|
|
|
|
|
|
|
|
const node = document.createElement('div');
|
|
|
|
|
|
|
|
const { end } = create_out_transition(node, () => config, {});
|
|
|
|
|
|
|
|
let error: Error | null = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
end(true);
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
error = e;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert.equal(error, null);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe('when the transition function returns a config object with defined tick function', () => {
|
|
|
|
|
|
|
|
describe('when calling the end function with reset param equals to true', () => {
|
|
|
|
|
|
|
|
it('should call the tick function', () => {
|
|
|
|
const node = document.createElement('div');
|
|
|
|
const node = document.createElement('div');
|
|
|
|
|
|
|
|
let tick = 0;
|
|
|
|
const transitionConfig: TransitionConfig = {
|
|
|
|
const transitionConfig: TransitionConfig = {
|
|
|
|
duration: 0
|
|
|
|
duration: 0,
|
|
|
|
|
|
|
|
tick: () => (tick += 1)
|
|
|
|
};
|
|
|
|
};
|
|
|
|
const { end } = create_out_transition(
|
|
|
|
const { end } = create_out_transition(
|
|
|
|
node,
|
|
|
|
node,
|
|
|
|
() => undefined,
|
|
|
|
() => transitionConfig,
|
|
|
|
transitionConfig
|
|
|
|
{}
|
|
|
|
);
|
|
|
|
);
|
|
|
|
let error: Error | null = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
end(true);
|
|
|
|
end(true);
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
error = e;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert.equal(error, null);
|
|
|
|
assert.equal(tick, 1);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|