test: improve create_out_transition tests

pull/7906/head
Bruno Calou 4 years ago
parent 6999b5c044
commit 14877b536e

@ -9,7 +9,7 @@ describe('transitions', () => {
before(() => { before(() => {
originalRequestAnimationFrame = global.requestAnimationFrame; originalRequestAnimationFrame = global.requestAnimationFrame;
global.requestAnimationFrame = cb => cb(); global.requestAnimationFrame = (cb) => cb();
}); });
after(() => { after(() => {
@ -21,18 +21,14 @@ describe('transitions', () => {
}); });
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 node = document.createElement('div');
const transitionConfig: TransitionConfig = { const { end } = create_out_transition(node, () => config, {});
duration: 0
};
const { end } = create_out_transition(
node,
() => undefined,
transitionConfig
);
let error: Error | null = null; let error: Error | null = null;
try { 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);
});
});
});
});
}); });

Loading…
Cancel
Save