ember-power-select icon indicating copy to clipboard operation
ember-power-select copied to clipboard

Length of dropdown list in integration tests.

Open far-fetched opened this issue 7 years ago • 1 comments

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 avatar Sep 27 '18 01:09 far-fetched

@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');

  • getDropdownItems is capable of getting the items when dropdown is not in open state so no need to perform await clickTrigger(".t-select-foo");

kprasadpvv avatar Nov 26 '20 15:11 kprasadpvv