Skip to content

[unit testing] table calls provider only once when filter is object #4067

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

Closed
wants to merge 13 commits into from

Conversation

caiquecastro
Copy link

@caiquecastro caiquecastro commented Sep 10, 2019

Describe the PR

A clear and concise description of what the pull request does.

PR checklist

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Enhancement
  • ARIA accessibility
  • Documentation update
  • Other (please describe)

Does this PR introduce a breaking change? (check one)

  • No
  • Yes (please describe)

The PR fulfills these requirements:

  • It's submitted to the dev branch, not the master branch
  • When resolving a specific issue, it's referenced in the PR's title (i.e. [...] (fixes #xxx[,#xxx]), where "xxx" is the issue number)
  • It should address only one issue or feature. If adding multiple features or fixing a bug and adding a new feature, break them into separate PRs if at all possible.
  • The title should follow the Conventional Commits naming convention (i.e. fix(alert): not alerting during SSR render, docs(badge): update pill examples, fix typos, chore: fix typo in README, etc). This is very important, as the CHANGELOG is generated from these messages.

If new features/enhancement/fixes are added or changed:

  • Includes documentation updates (including updating the component's package.json for slot and event changes)
  • Includes any needed TypeScript declaration file updates
  • New/updated tests are included and passing (if required)
  • Existing test suites are passing
  • The changes have not impacted the functionality of other components or directives
  • ARIA Accessibility has been taken into consideration (Does it affect screen reader users or keyboard only users? Clickable items should be in the tab index, etc.)

If adding a new feature, or changing the functionality of an existing feature, the PR's
description above includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

@codecov
Copy link

codecov bot commented Sep 10, 2019

Codecov Report

Merging #4067 into dev will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##              dev    #4067   +/-   ##
=======================================
  Coverage   99.86%   99.86%           
=======================================
  Files         238      238           
  Lines        4475     4475           
  Branches     1260     1260           
=======================================
  Hits         4469     4469           
  Misses          5        5           
  Partials        1        1
Impacted Files Coverage Δ
src/components/tooltip/helpers/bv-tooltip.js 99.6% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1eda4fe...b55d233. Read the comment docs.

@tmorehouse
Copy link
Member

If prop fields is not defined, it i possible for the provider to be called twice, once to lookup the fields, and then once when populating the items.

@caiquecastro
Copy link
Author

The fields are defined. I can update the tests to check it.

@tmorehouse
Copy link
Member

PR #4068 may fix this issue

@tmorehouse
Copy link
Member

tmorehouse commented Sep 10, 2019

Also note that the filter can only be an object when a filter-function is provided. The internal filter function can only handle strings or regular expressions. If anything other than a string or regular expression is passed, and a filter-function is not provided, then the filter criteria will be converted to an empty string ''.

EDIT: object is allowed when provider filtering is happening

// the provider is being called twice
expect(providerCallCount).toBe(2)

filter.a = '456';
Copy link
Member

Choose a reason for hiding this comment

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

Just setting this will not update the prop in Vue Test Utils. you need to call setProps on the wrapper

wrapper.setProps({ filter: filter })

return testItems.slice()
}

mount(BTable, {
Copy link
Member

Choose a reason for hiding this comment

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

When mounting, assign the return value to wrapper, so that it can be destroyed at the end of the test. otherwise it remains in the DOM during the other tests (and occupies memory space as well)

@tmorehouse
Copy link
Member

Confirmed: PR #4068 fixes your original issue re provider being called twice when filter is preset before mount and items is a provider function

@tmorehouse tmorehouse changed the title Calls provider only once when filter is object [unit testing] Calls provider only once when filter is object Sep 11, 2019
@tmorehouse tmorehouse changed the title [unit testing] Calls provider only once when filter is object [unit testing] table calls provider only once when filter is object Sep 11, 2019
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