Skip to content

chore: upgrade kcd-scripts dev dependency #1134

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 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,17 @@
"jest-snapshot-serializer-ansi": "^1.0.0",
"jest-watch-select-projects": "^2.0.0",
"jsdom": "^16.4.0",
"kcd-scripts": "^11.0.0",
"kcd-scripts": "^12.2.0",
"typescript": "^4.1.2"
},
"eslintConfig": {
"extends": [
"./node_modules/kcd-scripts/eslint.js",
"plugin:import/typescript"
],
"parserOptions": {
"ecmaVersion": 2020
},
"rules": {
"@typescript-eslint/prefer-includes": "off",
"import/prefer-default-export": "off",
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/fake-timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ test('recursive timers do not cause issues', async () => {
let recurse = true
function startTimer() {
setTimeout(() => {
// eslint-disable-next-line jest/no-conditional-in-test
if (recurse) startTimer()
}, 1)
}
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/role.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ test('accessible name filter implements TextMatch', () => {
expect(
getByRole('heading', {
name: (name, element) => {
// eslint-disable-next-line jest/no-conditional-in-test
return element.nodeName === 'H2' && name === 'Your Signature'
},
}),
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/wait-for-element-to-be-removed.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ test('rethrows non-testing-lib errors', () => {
const error = new Error('my own error')
return expect(
waitForElementToBeRemoved(() => {
// eslint-disable-next-line jest/no-conditional-in-test
if (throwIt) {
throw error
}
Expand Down
3 changes: 2 additions & 1 deletion src/__tests__/wait-for.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ test('does not work after it resolves', async () => {
context = 'act'
try {
const result = callback()
// eslint-disable-next-line jest/no-if
// eslint-disable-next-line jest/no-if, jest/no-conditional-in-test
if (typeof result?.then === 'function') {
const thenable = result
return {
Expand Down Expand Up @@ -319,6 +319,7 @@ test('does not work after it resolves', async () => {

await waitFor(
() => {
// eslint-disable-next-line jest/no-conditional-in-test
if (data === null) {
throw new Error('not found')
}
Expand Down
2 changes: 2 additions & 0 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ function jestFakeTimersAreEnabled() {
// legacy timers
setTimeout._isMockFunction === true ||
// modern timers
// Disabling linting rule - hasOwn is not available in Node 12/14
// eslint-disable-next-line prefer-object-has-own
Object.prototype.hasOwnProperty.call(setTimeout, 'clock')
)
}
Expand Down
12 changes: 8 additions & 4 deletions src/queries/label-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,23 @@ const queryAllByLabelText: AllByText = (
if (
matcher(label.content, label.formControl, text, matchNormalizer) &&
label.formControl
)
) {
labelledElements.push(label.formControl)
}
})
const labelsValue = labelList
.filter(label => Boolean(label.content))
.map(label => label.content)
if (
matcher(labelsValue.join(' '), labelledElement, text, matchNormalizer)
)
) {
labelledElements.push(labelledElement)
}
if (labelsValue.length > 1) {
labelsValue.forEach((labelValue, index) => {
if (matcher(labelValue, labelledElement, text, matchNormalizer))
if (matcher(labelValue, labelledElement, text, matchNormalizer)) {
labelledElements.push(labelledElement)
}

const labelsFiltered = [...labelsValue]
labelsFiltered.splice(index, 1)
Expand All @@ -97,8 +100,9 @@ const queryAllByLabelText: AllByText = (
text,
matchNormalizer,
)
)
) {
labelledElements.push(labelledElement)
}
}
})
}
Expand Down