test(ct-angular): improve output listener update test

This commit is contained in:
Younes Jaaidi 2024-04-11 17:17:10 +02:00
parent eefd6ea3a2
commit d83f9ee4a9
No known key found for this signature in database
GPG key ID: 3126C5717BDF3241

View file

@ -19,29 +19,27 @@ test('emit an submit event when the button is clicked', async ({ mount }) => {
test('replace existing listener when new listener is set', async ({ test('replace existing listener when new listener is set', async ({
mount, mount,
}) => { }) => {
let count = 0; let called = false;
const component = await mount(ButtonComponent, { const component = await mount(ButtonComponent, {
props: { props: {
title: 'Submit', title: 'Submit',
}, },
on: { on: {
submit() { submit() {},
count++;
},
}, },
}); });
component.update({ component.update({
on: { on: {
submit() { submit() {
count++; called = true;
}, },
}, },
}); });
await component.click(); await component.click();
expect(count).toBe(1); expect(called).toBe(true);
}); });
test('unsubscribe from events when the component is unmounted', async ({ test('unsubscribe from events when the component is unmounted', async ({