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

Port spec for Navbar #83

Merged
merged 4 commits into from
Sep 16, 2023
Merged

Port spec for Navbar #83

merged 4 commits into from
Sep 16, 2023

Conversation

kikuomax
Copy link
Collaborator

@kikuomax kikuomax commented Sep 4, 2023

Part of the series of PRs to port unit tests.

The following command should pass:

npx jest src/components/navbar

Related to:

Proposed Changes

  • Port spec for Navbar
  • Port spec for NavbarItem
  • Port spec for NavbarBurger
  • Port spec for NavbarDropdown

- Updates the unit tests (spec) of `Navbar` so that they can work with
  `@vue/test-utils` V2 and breaking changes:
    - Corrects v-model bindings:
        - property: `active` → `modelValue`
        - event: `update:active` → `update:modelValue`
    - Replaces `wrapper.contains` with a combination of `find` and
      `exists` because `wrapper.contains` no longer exists in
      `@vue/test-utils` V2.
    - Awaits `wrapper.setProps` and `wrapper.trigger` to make sure the
      subsequent tests verify the updated state.
    - Replaces the test on `wrapper.isVueInstance()` with presence of
      `wrapper.vm` because `wrapper.isVueInstance` no longer exists in
      `@vue/test-utils` V2.
    - Replaces `propsData` for `mount` with `props` because `propsData`
      might be deprecated in the future.
    - Refreshes the snapshot. I did not find any problems in the updated
      snapshot. However, the snpshot won't match until we fix the issue
      ntohq#29.
    - The tests won't pass until we fix the issue ntohq#28.

issue ntohq#1
- Updates the unit tests (spec) of `NavbarBurger` so that they can work
  with `@vue/test-utils` V2:
    - Specifies the element tag to the selector given to `wrapper.find`
      instead of testing the tag with `is`. Because `is` no longer
      exists in `@vue/test-utils` V2.
    - Awaits `wrapper.setProps` to make sure the subsequent assertions
      verify the updated state.
    - Replaces the test on `wrapper.isVueInstance()` with presence of
      `wrapper.vm` because `wrapper.isVueInstance` no longer exists in
      `@vue/test-utils` V2.
    - Refreshes the snapshot. I did not find any problems in the updated
      snapshot. However, the snapshot won't match until we fix the issue
      ntohq#29.

issue ntohq#1
- Updates the unit tests (spec) of `NavbarItem` so that they can work
  with `@vue/test-utils` V2 and Vue 3:
    - Replaces `listeners` option for `shallowMount` with `on{event}`
      props, because `listeners` no longer works on `@vue/test-utils` V2
      but `on{event}` prop does the equivalent job on Vue 3 instead.
    - Mounts `stubBNavBar` and inserts `BNavbarItem` into its default
      slot instead of specifying `stubBNavBar` as `parentComponents`,
      because `parentComponents` no longer works on `@vue/test-utils`
      V2.
    - Replaces `wrapper.contains` with a combination of `find` and
      `exists` because `wrapper.contains` no longer exists in
      `@vue/test-utils` V2.
    - A test on a tag name is merged with a selector given to `find`.
    - Awaits `wrapper.setProps` to make sure the subsequent assertions
      verify the updated state.
    - Replaces `wrapper.name()` with `wrapper.vm.$options.name` because
      `wrapper.name` no longer exists in `@vue/test-utils` V2.
    - Replaces the test on `wrapper.isVueInstance()` with presence of
      `wrapper.vm` because `wrapper.isVueInstance` no longer exists in
      `@vue/test-utils` V2.
    - Fixes the event type for "click": `KeyboardEvent` → `MouseEvent`.
    - Replaces `sinon.stub` with `jest.fn`. No longer imports `sinon`.

issue ntohq#1
- Updates the unit tests (spec) of `NavbarDropdown` so that they can
  work with `@vue/test-utils` V2:
    - Awaits `wrapper.setProps` to make sure the subsequent assertions
      verify the updated state.
    - Replaces `wrapper.name()` with `wrapper.vm.$options.name` because
      `wrapper.name` no longer exists in `@vue/test-utils` V2.
    - Replaces the test on `wrapper.isVueInstance()` with presence of
      `wrapper.vm` because `wrapper.isVueInstance` no loger exists in
      `@vue/test-utils` V2.
    - Refreshes the snapshot. I found the updated snapshot had two
      `div` elements with `navbar-dropdown` class, but this is fine
      because they were introduced after the old snapshot was recorded.

issue ntohq#1
@kikuomax kikuomax requested a review from wesdevpro September 4, 2023 04:05
@wesdevpro wesdevpro merged commit 5498605 into ntohq:dev Sep 16, 2023
@kikuomax kikuomax deleted the test-navbar branch September 18, 2023 01:40
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