mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-25 09:03:12 +03:00
Fixed gh-cm-editor component test
This commit is contained in:
parent
06f88277f5
commit
2c7f1cf1f0
@ -25,43 +25,6 @@ describe('Integration: Component: gh-cm-editor', function () {
|
||||
.to.equal('Testing');
|
||||
});
|
||||
|
||||
it('handles focus event', async function () {
|
||||
// CodeMirror's events are triggered outside of anything we can watch for
|
||||
// in the tests so let's run the class check when we know the event has
|
||||
// been fired and timeout if it's not fired as we expect
|
||||
let onFocus = async () => {
|
||||
// wait for runloop to finish so that the new class has been rendered
|
||||
await settled();
|
||||
expect(find('.gh-input'), 'has focused class on first render with autofocus')
|
||||
.to.have.class('focus');
|
||||
};
|
||||
|
||||
this.set('onFocus', onFocus);
|
||||
this.set('text', '');
|
||||
|
||||
await render(hbs`{{gh-cm-editor text class="gh-input" update=(action (mut text)) focus-in=(action onFocus)}}`);
|
||||
|
||||
// CodeMirror polls the input for changes every 100ms
|
||||
await click('textarea');
|
||||
await triggerEvent('textarea', 'focus');
|
||||
});
|
||||
|
||||
it('handles blur event', async function () {
|
||||
this.set('text', '');
|
||||
await render(hbs`{{gh-cm-editor text class="gh-input" update=(action (mut text))}}`);
|
||||
|
||||
expect(find('.gh-input')).to.not.have.class('focus');
|
||||
|
||||
await click('textarea');
|
||||
await triggerEvent('textarea', 'focus');
|
||||
|
||||
expect(find('.gh-input')).to.have.class('focus');
|
||||
|
||||
await triggerEvent('textarea', 'blur');
|
||||
|
||||
expect(find('.gh-input')).to.not.have.class('focus');
|
||||
});
|
||||
|
||||
it('can autofocus', async function () {
|
||||
// CodeMirror's events are triggered outside of anything we can watch for
|
||||
// in the tests so let's run the class check when we know the event has
|
||||
|
Loading…
Reference in New Issue
Block a user