Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: testing-library/jest-dom
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v6.4.2
Choose a base ref
...
head repository: testing-library/jest-dom
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v6.4.5
Choose a head ref
  • 4 commits
  • 6 files changed
  • 3 contributors

Commits on Apr 1, 2024

  1. refactor: replace lodash with own implementation when possible (#593)

    re-taro authored Apr 1, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    bd82f64 View commit details

Commits on May 3, 2024

  1. fix: Updates role support for aria-required attribute in `toBeRequire…

    …d` (#590)
    JatinRanka authored May 3, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    20aca33 View commit details
  2. fix(infra): codecoverage token addition (#600)

    MatanBobi authored May 3, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    f03a582 View commit details
  3. fix: add js suffix to isEqualWith import (#599)

    MatanBobi authored May 3, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    e8c8b13 View commit details
Showing with 19 additions and 15 deletions.
  1. +4 −1 .github/workflows/validate.yml
  2. +1 −1 package.json
  3. +3 −0 src/to-be-required.js
  4. +2 −3 src/to-have-form-values.js
  5. +1 −1 src/to-have-value.js
  6. +8 −9 src/utils.js
5 changes: 4 additions & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -38,7 +38,10 @@ jobs:
FORCE_COLOR: true

- name: ⬆️ Upload coverage report
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}

release:
needs: main
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -86,7 +86,7 @@
"chalk": "^3.0.0",
"css.escape": "^1.5.1",
"dom-accessibility-api": "^0.6.3",
"lodash": "^4.17.15",
"lodash": "^4.17.21",
"redent": "^3.0.0"
},
"devDependencies": {
3 changes: 3 additions & 0 deletions src/to-be-required.js
Original file line number Diff line number Diff line change
@@ -15,10 +15,13 @@ const UNSUPPORTED_INPUT_TYPES = [
]

const SUPPORTED_ARIA_ROLES = [
'checkbox',
'combobox',
'gridcell',
'listbox',
'radiogroup',
'spinbutton',
'textbox',
'tree',
]

5 changes: 2 additions & 3 deletions src/to-have-form-values.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import isEqualWith from 'lodash/isEqualWith.js'
import uniq from 'lodash/uniq.js'
import escape from 'css.escape'
import {
checkHtmlElement,
compareArraysAsSet,
getSingleElementValue,
compareArraysAsSet,
} from './utils'

// Returns the combined value of several elements that have the same name
// e.g. radio buttons or groups of checkboxes
function getMultiElementValue(elements) {
const types = uniq(elements.map(element => element.type))
const types = [...new Set(elements.map(element => element.type))]
if (types.length !== 1) {
throw new Error(
'Multiple form elements with the same name must be of the same type',
2 changes: 1 addition & 1 deletion src/to-have-value.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import isEqualWith from 'lodash/isEqualWith.js'
import {
checkHtmlElement,
compareArraysAsSet,
getMessage,
getSingleElementValue,
compareArraysAsSet,
} from './utils'

export function toHaveValue(htmlElement, expectedValue) {
17 changes: 8 additions & 9 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import redent from 'redent'
import isEqual from 'lodash/isEqual.js'
import {parse} from '@adobe/css-tools'

class GenericTypeError extends Error {
@@ -212,13 +211,6 @@ function getSingleElementValue(element) {
}
}

function compareArraysAsSet(a, b) {
if (Array.isArray(a) && Array.isArray(b)) {
return isEqual(new Set(a), new Set(b))
}
return undefined
}

function toSentence(
array,
{wordConnector = ', ', lastWordConnector = ' and '} = {},
@@ -228,6 +220,13 @@ function toSentence(
)
}

function compareArraysAsSet(arr1, arr2) {
if (Array.isArray(arr1) && Array.isArray(arr2)) {
return [...new Set(arr1)].every(v => new Set(arr2).has(v))
}
return undefined
}

export {
HtmlElementTypeError,
NodeTypeError,
@@ -240,6 +239,6 @@ export {
normalize,
getTag,
getSingleElementValue,
compareArraysAsSet,
toSentence,
compareArraysAsSet,
}