Skip to content

Commit

Permalink
fix quick pick user ordered values test
Browse files Browse the repository at this point in the history
  • Loading branch information
mattseddon committed Aug 13, 2024
1 parent 8448e14 commit d2d5625
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions extension/src/test/suite/vscode/quickPick.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from '../../../vscode/quickPick'
import { selectQuickPickItem, selectMultipleQuickPickItems } from '../util'
import { Title } from '../../../vscode/title'
import { sameContents } from '../../../util/array'

suite('Quick Pick Test Suite', () => {
const disposable = Disposable.fn()
Expand Down Expand Up @@ -213,17 +214,25 @@ suite('Quick Pick Test Suite', () => {
maxSelectedItems
)

await selectMultipleQuickPickItems(
[5, 2, 1],
items.length,
quickPick,
false
)
const expectedItemsSelected = new Promise<void>(resolve => {
quickPick.onDidChangeSelection(() => {
if (
quickPick.items.length === maxSelectedItems &&
sameContents(
quickPick.selectedItems.map(({ value }) => value),
quickPick.items.map(({ value }) => value)
)
) {
resolve(undefined)
}
})
})

await Promise.all([
selectMultipleQuickPickItems([5, 2, 1], items.length, quickPick, false),
expectedItemsSelected
])

expect(
quickPick.selectedItems,
'the max number of items are selected'
).to.have.lengthOf(maxSelectedItems)
expect(
quickPick.items,
'all items which could be selected are hidden'
Expand Down

0 comments on commit d2d5625

Please sign in to comment.