mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-03 03:55:26 +03:00
6dabb84e0a
closes https://github.com/TryGhost/Ghost/issues/8269 - swaps the usage of our custom `gh-dropdown` component in the user menu dropdown for the `ember-wormhole` based `ember-basic-dropdown` that is used elsewhere in the app and will fully replace `gh-dropdown` in the future - adds `gh-basic-dropdown` component that extends from `ember-basic-dropdown` and hooks into our `dropdown` service so that we can programatically close dropdowns from disparate areas of the app - modifies the `body-event-listener` mixin to pass the click event through to it's consumers - modifies the `bodyClick` handler in the `dropdown` service to check if the click actually originated from an ember-basic-dropdown element - this body click handler will go away once we've fully switched to `gh-basic-dropdown` - adds `ember-native-dom-helpers` to provide consistency between acceptance and integration tests (this is the start of another refactor, eventually this addon will disappear as part of ember's [grand testing unification project](https://github.com/rwjblue/rfcs/blob/42/text/0000-grand-testing-unification.md))
37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
import {expect} from 'chai';
|
|
import {describe, it} from 'mocha';
|
|
import {setupComponentTest} from 'ember-mocha';
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
import {clickTrigger} from '../../helpers/ember-basic-dropdown';
|
|
import {find} from 'ember-native-dom-helpers';
|
|
import $ from 'jquery';
|
|
import run from 'ember-runloop';
|
|
|
|
describe('Integration: Component: gh-basic-dropdown', function() {
|
|
setupComponentTest('gh-basic-dropdown', {
|
|
integration: true
|
|
});
|
|
|
|
it('closes when dropdown service fires close event', function() {
|
|
let dropdownService = this.container.lookup('service:dropdown');
|
|
|
|
this.render(hbs`
|
|
{{#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}}
|
|
`);
|
|
|
|
clickTrigger();
|
|
expect($(find('#dropdown-is-opened'))).to.exist;
|
|
|
|
run(() => {
|
|
dropdownService.closeDropdowns();
|
|
});
|
|
|
|
expect($(find('#dropdown-is-opened'))).to.not.exist;
|
|
});
|
|
});
|