test: add create_out_transition test

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

@ -232,7 +232,7 @@ export function create_out_transition(node: Element & ElementCSSInlineStyle, fn:
}
return {
end(reset) {
end(reset: boolean) {
if (reset && config?.tick) {
config.tick(1, 0);
}

@ -19,7 +19,7 @@ describe('dom', () => {
describe('when parentNode does not exist', () => {
it('should not throw an exception', () => {
const childWithoutParent = document.createElement('div');
let error = null;
let error: Error | null = null;
try {
detach(childWithoutParent);

@ -0,0 +1,49 @@
import * as assert from 'assert';
import { create_out_transition, group_outros } from 'svelte/internal';
import { TransitionConfig } from 'svelte/transition';
declare const global: any;
describe('transitions', () => {
let originalRequestAnimationFrame: () => void;
before(() => {
originalRequestAnimationFrame = global.requestAnimationFrame;
global.requestAnimationFrame = cb => cb();
});
after(() => {
global.requestAnimationFrame = originalRequestAnimationFrame;
});
beforeEach(() => {
group_outros();
});
describe('create_out_transition', () => {
describe('when then transition function returns undefined', () => {
describe('when calling the end function with reset param equals to true', () => {
it('should not throw an exception', () => {
const node = document.createElement('div');
const transitionConfig: TransitionConfig = {
duration: 0
};
const { end } = create_out_transition(
node,
() => undefined,
transitionConfig
);
let error: Error | null = null;
try {
end(true);
} catch (e) {
error = e;
}
assert.equal(error, null);
});
});
});
});
});
Loading…
Cancel
Save