mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 09:52:06 +03:00
47 lines
1.4 KiB
JavaScript
47 lines
1.4 KiB
JavaScript
/* jshint expr:true */
|
|
import {expect} from 'chai';
|
|
import {describe, it} from 'mocha';
|
|
import {setupComponentTest} from 'ember-mocha';
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
import run from 'ember-runloop';
|
|
|
|
describe('Integration: Component: gh-cm-editor', function () {
|
|
setupComponentTest('gh-cm-editor', {
|
|
integration: true
|
|
});
|
|
|
|
it('handles editor events', function () {
|
|
this.set('text', '');
|
|
|
|
this.render(hbs`{{gh-cm-editor text class="gh-input" update=(action (mut text))}}`);
|
|
let input = this.$('.gh-input');
|
|
|
|
expect(input.hasClass('focused'), 'has focused class on first render')
|
|
.to.be.false;
|
|
|
|
run(() => {
|
|
input.find('textarea').trigger('focus');
|
|
});
|
|
|
|
expect(input.hasClass('focused'), 'has focused class after focus')
|
|
.to.be.true;
|
|
|
|
run(() => {
|
|
input.find('textarea').trigger('blur');
|
|
});
|
|
|
|
expect(input.hasClass('focused'), 'loses focused class on blur')
|
|
.to.be.false;
|
|
|
|
run(() => {
|
|
// access CodeMirror directly as it doesn't pick up changes
|
|
// to the textarea
|
|
let cm = input.find('.CodeMirror').get(0).CodeMirror;
|
|
cm.setValue('Testing');
|
|
});
|
|
|
|
expect(this.get('text'), 'text value after CM editor change')
|
|
.to.equal('Testing');
|
|
});
|
|
});
|