2017-04-05 17:26:01 +03:00
|
|
|
import hbs from 'htmlbars-inline-precompile';
|
2019-01-02 12:58:55 +03:00
|
|
|
import {clickTrigger} from 'ember-basic-dropdown/test-support/helpers';
|
2017-05-29 21:50:03 +03:00
|
|
|
import {describe, it} from 'mocha';
|
|
|
|
import {expect} from 'chai';
|
2019-01-02 12:58:55 +03:00
|
|
|
import {find, render, settled} from '@ember/test-helpers';
|
|
|
|
import {setupRenderingTest} from 'ember-mocha';
|
2017-04-05 17:26:01 +03:00
|
|
|
|
2018-01-05 18:38:23 +03:00
|
|
|
describe('Integration: Component: gh-basic-dropdown', function () {
|
2019-01-02 12:58:55 +03:00
|
|
|
setupRenderingTest();
|
2017-04-05 17:26:01 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
it('closes when dropdown service fires close event', async function () {
|
|
|
|
let dropdownService = this.owner.lookup('service:dropdown');
|
2017-04-05 17:26:01 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
await render(hbs`
|
2017-04-05 17:26:01 +03:00
|
|
|
{{#gh-basic-dropdown as |dropdown|}}
|
|
|
|
<button class="ember-basic-dropdown-trigger" onclick={{dropdown.actions.toggle}}></button>
|
|
|
|
{{#if dropdown.isOpen}}
|
|
|
|
<div id="dropdown-is-opened"></div>
|
|
|
|
{{/if}}
|
|
|
|
{{/gh-basic-dropdown}}
|
|
|
|
`);
|
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
await clickTrigger();
|
|
|
|
expect(find('#dropdown-is-opened')).to.exist;
|
2017-04-05 17:26:01 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
dropdownService.closeDropdowns();
|
|
|
|
await settled();
|
2017-04-05 17:26:01 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(find('#dropdown-is-opened')).to.not.exist;
|
2017-04-05 17:26:01 +03:00
|
|
|
});
|
|
|
|
});
|