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

refactored onKeyDown to be easier to read, and added test #943

Conversation

brandonrainey
Copy link

#918

Changed the onKeyDown function in search-display-controller to be easier to read. Also created a new test file to test preserved behavior between the current and new function.

The test passes, but I'm not sure if the test is up to par or not, but I tried to replicate as well as I could figure out how to.

@brandonrainey brandonrainey requested a review from a team as a code owner May 15, 2024 01:20
@Kuuuube
Copy link
Member

Kuuuube commented May 15, 2024

Add this to the tests:

ctrl + a
alt + a
meta + a
backspace
ctrl + backspace
arrow key down

Copy link
Collaborator

@jamesmaa jamesmaa left a comment

Choose a reason for hiding this comment

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

Thanks for doing this 😄

My biggest concern stems from replicating the search-display-controller logic in the tests because even though they verify the correctness of the current yomitan, if the logic of those if statement changes in the future, we would need to update the corresponding tests, which I don't expect future developers to remember to do.

test/search-display-controller.test.js Outdated Show resolved Hide resolved
test/search-display-controller.test.js Outdated Show resolved Hide resolved
test/search-display-controller.test.js Outdated Show resolved Hide resolved
Copy link
Member

@Kuuuube Kuuuube left a comment

Choose a reason for hiding this comment

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

It would also be good to include this test in the package.json. Maybe something like this:

"test:search-display-controller": "vitest run --config test/data/vitest.search-display-controller.config.json",

With test/data/vitest.search-display-controller.config.json looking like this:

{
    "test": {
        "include": [
            "test/search-display-controller.test.js"
        ]
    }
}

Then npm run test:search-display-controller can be added to "test" command in package.json as well.

test/search-display-controller.test.js Outdated Show resolved Hide resolved
test/search-display-controller.test.js Outdated Show resolved Hide resolved
test/search-display-controller.test.js Outdated Show resolved Hide resolved
ext/js/display/search-display-controller.js Outdated Show resolved Hide resolved
@Kuuuube
Copy link
Member

Kuuuube commented May 17, 2024

Actually disregard the part about adding a specific script for this in the package. It's probably not important enough to need that. It runs with test:js anyways.

Copy link
Member

@Kuuuube Kuuuube left a comment

Choose a reason for hiding this comment

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

Thank you for taking the time to add this!

@jamesmaa jamesmaa added this pull request to the merge queue May 17, 2024
Merged via the queue into yomidevs:master with commit a3ed56c May 17, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants