Ghost/ghost/admin/tests/integration/components/gh-search-input-test.js

46 lines
1.2 KiB
JavaScript
Raw Normal View History

/* jshint expr:true */
import Pretender from 'pretender';
import hbs from 'htmlbars-inline-precompile';
import wait from 'ember-test-helpers/wait';
import {describe, it} from 'mocha';
import {expect} from 'chai';
import {run} from '@ember/runloop';
import {setupComponentTest} from 'ember-mocha';
2016-11-24 01:50:57 +03:00
describe('Integration: Component: gh-search-input', function () {
setupComponentTest('gh-search-input', {
integration: true
2016-11-24 01:50:57 +03:00
});
2016-11-24 01:50:57 +03:00
let server;
2016-11-24 01:50:57 +03:00
beforeEach(function () {
server = new Pretender();
});
2016-11-24 01:50:57 +03:00
afterEach(function () {
server.shutdown();
});
2016-11-24 01:50:57 +03:00
it('renders', function () {
// renders the component on the page
this.render(hbs`{{gh-search-input}}`);
2016-11-24 01:50:57 +03:00
expect(this.$('.ember-power-select-search input')).to.have.length(1);
});
2016-11-24 01:50:57 +03:00
it('opens the dropdown on text entry', function (done) {
this.render(hbs`{{gh-search-input}}`);
// enter text to trigger search
run(() => {
this.$('input[type="search"]').val('test').trigger('input');
});
2016-11-24 01:50:57 +03:00
wait().then(() => {
expect(this.$('.ember-basic-dropdown-content').length).to.equal(1);
done();
});
2016-11-24 01:50:57 +03:00
});
});