|
|
|
|
@ -9,7 +9,7 @@ describe('transitions', () => {
|
|
|
|
|
|
|
|
|
|
before(() => {
|
|
|
|
|
originalRequestAnimationFrame = global.requestAnimationFrame;
|
|
|
|
|
global.requestAnimationFrame = cb => cb();
|
|
|
|
|
global.requestAnimationFrame = (cb) => cb();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
after(() => {
|
|
|
|
|
@ -21,18 +21,14 @@ describe('transitions', () => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
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', () => {
|
|
|
|
|
it('should not throw an exception', () => {
|
|
|
|
|
const noTickConfigs: TransitionConfig[] = [undefined, null, {}];
|
|
|
|
|
|
|
|
|
|
noTickConfigs.forEach((config) => {
|
|
|
|
|
const node = document.createElement('div');
|
|
|
|
|
const transitionConfig: TransitionConfig = {
|
|
|
|
|
duration: 0
|
|
|
|
|
};
|
|
|
|
|
const { end } = create_out_transition(
|
|
|
|
|
node,
|
|
|
|
|
() => undefined,
|
|
|
|
|
transitionConfig
|
|
|
|
|
);
|
|
|
|
|
const { end } = create_out_transition(node, () => config, {});
|
|
|
|
|
let error: Error | null = null;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
@ -46,4 +42,27 @@ describe('transitions', () => {
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
let tick = 0;
|
|
|
|
|
const transitionConfig: TransitionConfig = {
|
|
|
|
|
duration: 0,
|
|
|
|
|
tick: () => (tick += 1)
|
|
|
|
|
};
|
|
|
|
|
const { end } = create_out_transition(
|
|
|
|
|
node,
|
|
|
|
|
() => transitionConfig,
|
|
|
|
|
{}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
end(true);
|
|
|
|
|
|
|
|
|
|
assert.equal(tick, 1);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|