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 Table #58

Merged
merged 4 commits into from
Sep 2, 2023
Merged

Port spec for Table #58

merged 4 commits into from
Sep 2, 2023

Conversation

kikuomax
Copy link
Collaborator

@kikuomax kikuomax commented Sep 1, 2023

Part of the series of PRs to port unit tests.

The following command should pass:

npx jest src/components/table

You will see the following warning, though, this should happen only in the test environment:

[Vue warn]: Invalid prop: type check failed for prop "currentSortColumn". Expected Object, got String with value "val".

Related to:

Proposed Changes

  • Port spec for Table
  • Port spec for TableColumn
  • Port spec for TableMobileSort
  • Fix a test-specific issue on TableMobileSort

- Updates the unit tests (spec) of `Table` so that they work with Vue 3
  and `@vue/test-utils` V2:
    - Removes `setVueInstance` because it does nothing on `buefy-next`.
    - Replaces `sinon`'s `useFakeTimers` with a combination of
      `jest.useFakeTimers` and `jest.advanceTimersByTime` so that we
      will be able to remove `sinon` from dependencies in the future.
      Awaits `$nextTick` after `jest.advanceTimersByTime` to make sure
      DOM is updated, otherwise the test fails.
    - Replaces `wrapper.find` with `wrapper.findComponent` to locate a
      component, because `wrapper.find` is dedicated to finding a DOM
      element on `@vue/test-utils` V2.
    - Replaces `isEmpty` of `Wrapper` with a combination of `element`
      and `toBeEmptyDOMElement`, because `Wrapper` no longer provides
      `isEmpty` on `@vue/test-utils` V2.
    - Replaces `contains` of `Wrapper` with a combination of `find` and
      `exists`, because `Wrapper` no longer provides `contains` on
      `@vue/test-utils` V2.
    - 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.
    - Awaits `wrapper.setProps` to make sure the subsequent tests verify
      the updated state.
    - Replaces `propsData` with `props`, because `propsData` might be
      deprecated in the future.
    - Refreshes the snapshot. I temporarily fixed the bug I found while
      updating the spec (ntohq#8) to make the snapshot.
    - NOTE: the tests won't pass until the bug is fixed:
        - ntohq#8

issue ntohq#1
- Updates the unit tests (spec) of `TableColumn` so that they can work
  with `@vue/test-utils` V2:
    - Replaces `find` with `findComponent` because `find` is dedicated
      to DOM elements on `@vue/test-utils` V2.
    - 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.
    - Removes the `sync` option for `mount` because it no longer exists
      in `@vue/test-utils`. It neither has any effect.

issue ntohq#1
- Updates the unit tests (spec) of `TableMobileSort` so that they can
  work with `@vue/test-utils` V2:
    - Awaits `wrapper.setProps` to make sure the subsequent tests verify
      the updated state. Also replaces an old style async test case with
      async/await syntax.
    - 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.
    - Removes `sync` option for `shallowMount` because it no longer
      exists in `@vue/test-utils` V2 and has no effect.

  The tests won't pass until the issue mentioned in the following
  comment is fixed:
    - ntohq#1 (comment)

issue ntohq#1
- Fixes the issue where `TableMobileSort` crashed at initialization if
  `columns` was `null` or `undefined`. This happened in unit tests. I do
  not think users of Buefy face this issue.

issue ntohq#1 (comment)
@wesdevpro wesdevpro merged commit b61c9a2 into ntohq:dev Sep 2, 2023
@kikuomax kikuomax deleted the test-table branch September 4, 2023 02:03
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