Skip to content

Commit

Permalink
feature(Autocomplete) implemented spec test for selectOptions materia…
Browse files Browse the repository at this point in the history
  • Loading branch information
gselderslaghs committed Jan 6, 2025
1 parent 2c93bd2 commit 8b43f78
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions spec/tests/autocomplete/autocompleteSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,5 +263,22 @@ describe('Autocomplete Plugin', () => {
done();
}, 10);
});
it('setOptions should select multiple options', (done) => {
const normal = document.querySelector('#normal-autocomplete');
const autocompleteInstance = resetAutocomplete(normal, [
{ id: 1, text: 'Value A' },
{ id: 2, text: 'Value B' },
{ id: 3, text: 'Value C' }
]);
const selectOptions = [2, 3];
const autocomplete = M.Autocomplete.getInstance(normal)
autocomplete.selectOptions(selectOptions);
setTimeout(() => {
expect(autocomplete.selectedValues.filter((value) => !(selectOptions.indexOf(value.id) === -1)).length === selectOptions.length)
.withContext('filtered selectValues based on selectOptions should match')
.toBe(true);
done();
}, 10)
});
});
});

0 comments on commit 8b43f78

Please sign in to comment.