Skip to content

WIP: fix off once#1376

Open
bonkalol wants to merge 2 commits intov4from
bonkalol/fix-emitter-off
Open

WIP: fix off once#1376
bonkalol wants to merge 2 commits intov4from
bonkalol/fix-emitter-off

Conversation

@bonkalol
Copy link
Member

@bonkalol bonkalol commented Aug 6, 2024

No description provided.

const dummy = ctx.$normalParent;

const handler = () => {
globalThis.testResult = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше юзать JSHandle для этих целей:

const testHandle = page.evaluateHandle(() => ({value: false}));

await childComponent.evaluate((ctx, testHandle) => {
  const handler = () => {
    testHandle.value = true;
  };

  dummy?.once('hook:deactivated', handler);

	ctx.unsafe.async.worker(() => {
		dummy?.off('hook:deactivated', handler);
	});
}, testHandle);

await test.expect(testHandle.evaluate((ctx) => ctx.value)).resolves.toBeFalsy();

});
});

await BOM.waitForIdleCallback(page);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Имхо тест-кейс очень специфичный надо его в test-suite с активацией/деактивацией

Либо сделать простой тест с явным вызовом emit произвольного события

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants