From 8844ebdb2dc2f482de84cf5b3a1c8e90e685a4a8 Mon Sep 17 00:00:00 2001 From: Younes Jaaidi Date: Mon, 13 Nov 2023 22:52:16 +0100 Subject: [PATCH] test(ct): test output listener replacement --- .../ct-angular/tests/events.spec.ts | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/tests/components/ct-angular/tests/events.spec.ts b/tests/components/ct-angular/tests/events.spec.ts index 3abc6816ee..99c1ac484c 100644 --- a/tests/components/ct-angular/tests/events.spec.ts +++ b/tests/components/ct-angular/tests/events.spec.ts @@ -16,6 +16,36 @@ test('emit an submit event when the button is clicked', async ({ mount }) => { expect(messages).toEqual(['hello']); }); +test('replace existing listener when new listener is set', async ({ + mount, +}) => { + test.skip(true, '🚧 work in progress'); + + let count = 0; + + const component = await mount(ButtonComponent, { + props: { + title: 'Submit', + }, + on: { + submit() { + count++; + }, + }, + }); + + component.update({ + on: { + submit() { + count++; + }, + }, + }); + + await component.click(); + expect(count).toBe(1); +}); + test('unsubscribe from events when the component is unmounted', async ({ mount, page, @@ -23,7 +53,7 @@ test('unsubscribe from events when the component is unmounted', async ({ test.skip(true, '🚧 work in progress'); const component = await mount(OutputComponent, { on: { - answerChange: () => {}, + answerChange() {}, }, });