Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dispatchKeyboardEvent keydown Control event.ctrlKey is not true #623

Open
Julian-B90 opened this issue Aug 1, 2023 · 0 comments
Open

dispatchKeyboardEvent keydown Control event.ctrlKey is not true #623

Julian-B90 opened this issue Aug 1, 2023 · 0 comments

Comments

@Julian-B90
Copy link

Is this a regression?

Yes

Description

I have an Angular app in which I have a HostListener.

   @HostListener('document:keydown', ['$event'])
    onKeyDown(event: KeyboardEvent) {
        // Handle keydown event here
        if (event.ctrlKey || event.metaKey) {
            this.service.ctrlMode(true);
        }
    }

This is my test:

    it('should be press ctrKey', () => {
        spectator.dispatchKeyboardEvent(spectator.element, 'keydown', { key: 'a', keyCode: 65 });

        expect(service.ctrlMode()).toBe(false);

        spectator.dispatchKeyboardEvent(spectator.element, 'keydown', { key: 'Control', keyCode: 17 });

        expect(service.ctrlMode()).toBe(true);
    });

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

When I call spectator.dispatchKeyboardEvent(spectator.element, 'keydown', { key: 'Control', keyCode: 17 }); the evten.ctrlKey are not true.

Please provide the environment you discovered this bug in

"jest": "^29.5.0",
"@ngneat/spectator": "^15.0.1",

Anything else?

No response

Do you want to create a pull request?

No

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

No branches or pull requests

1 participant