Length of dropdown list in integration tests.
During integration test, checking rendered dropdown's length doesn't work. (according docs https://ember-power-select.com/docs/test-helpers):
await clickTrigger(".t-select-foo");
assert.equal($('.ember-power-select-dropdown').length, 1, 'Dropdown is rendered');
nor
await clickTrigger(".t-select-foo");
assert.equal($('.ember-power-select-options').length, 1, 'Dropdown has 1 item');
I assume that is because dropdown is rendered inside:
<div id='ember-basic-dropdown-wormhole'>
which is rendered out of the scope of component where I use ember-power-select, therefore$ cannot find dropdown 'inside' component. Correct me if I am wrong.
Is there any other way of checking length od dropdown list? (other than do it in acceptance test)
@far-fetched , This may be too old,
The support is added in PR.
You can use getDropdownItems from test helpers to get the list and get it's length.
in your tests import getDropdownItems:
import { getDropdownItems } from 'ember-power-select/test-support/helpers';
and in test assert
let displayedOptions = await getDropdownItems('.t-select-foo .ember-power-select-trigger'); assert.deepEqual(displayedOptions.length, 3, 'length of elements in dropdown should be same as passed elements');
-
getDropdownItemsis capable of getting the items when dropdown is not in open state so no need to performawait clickTrigger(".t-select-foo");