Skip to content

Commit f80f8df

Browse files
authored
chore(unit testing): form-group test conversion (#2984)
1 parent b4f8520 commit f80f8df

File tree

4 files changed

+360
-173
lines changed

4 files changed

+360
-173
lines changed

src/components/form-group/fixtures/form-group.html

Lines changed: 0 additions & 112 deletions
This file was deleted.

src/components/form-group/fixtures/form-group.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/components/form-group/form-group.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import BFormValidFeedback from '../form/form-valid-feedback'
2121
const NAME = 'BFormGroup'
2222

2323
// Selector for finding first input in the form-group
24-
const SELECTOR = 'input:not(:disabled),textarea:not(:disabled),select:not(:disabled)'
24+
const SELECTOR = 'input:not([disabled]),textarea:not([disabled]),select:not([disabled])'
2525

2626
// Memoize this function to return cached values to
2727
// save time in computed functions
@@ -338,7 +338,7 @@ export default (resolve, reject) => {
338338
// feedback IDs if the form-group's state is explicitly valid or invalid.
339339
return (
340340
[this.descriptionId, this.invalidFeedbackId, this.validFeedbackId]
341-
.filter(i => i)
341+
.filter(Boolean)
342342
.join(' ') || null
343343
)
344344
}
@@ -386,11 +386,15 @@ export default (resolve, reject) => {
386386
if (input) {
387387
const adb = 'aria-describedby'
388388
let ids = (getAttr(input, adb) || '').split(/\s+/)
389+
add = (add || '').split(/\s+/)
389390
remove = (remove || '').split(/\s+/)
390391
// Update ID list, preserving any original IDs
392+
// and ensuring the ID's are unique
391393
ids = ids
392394
.filter(id => !arrayIncludes(remove, id))
393-
.concat(add || '')
395+
.concat(add)
396+
.filter(Boolean)
397+
ids = keys(ids.reduce((memo, id) => ({ ...memo, [id]: true }), {}))
394398
.join(' ')
395399
.trim()
396400
if (ids) {

0 commit comments

Comments
 (0)