You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/test/runtime/samples/constructor-pass-context/_config.js

33 lines
864 B

export default {
async test({ assert, target, window }) {
const Component = require('./Component.svelte').default;
const called = [];
const component = new Component({
target,
context: new Map([
['key', 'svelte'],
['fn', (value) => called.push(value)]
])
});
assert.htmlEqual(target.innerHTML, '<div>svelte</div><button></button>');
const button = target.querySelector('button');
await button.dispatchEvent(new window.MouseEvent('click'));
assert.deepEqual(called, ['hello world']);
component.$destroy();
},
test_ssr({ assert }) {
const Component = require('./Component.svelte').default;
const called = [];
const { html } = Component.render(undefined, { context: new Map([
['key', 'svelte'],
['fn', (value) => called.push(value)]
]) });
assert.htmlEqual(html, '<div>svelte</div><button></button>');
}
};