2016-06-18 14:44:23 +03:00
|
|
|
import { expect } from 'chai';
|
|
|
|
import {
|
|
|
|
describeComponent,
|
|
|
|
it
|
|
|
|
} from 'ember-mocha';
|
2016-06-30 13:21:47 +03:00
|
|
|
import run from 'ember-runloop';
|
2016-06-18 14:44:23 +03:00
|
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
|
|
|
|
|
|
describeComponent(
|
|
|
|
'gh-trim-focus-input',
|
|
|
|
'Integration: Component: gh-trim-focus-input',
|
|
|
|
{
|
|
|
|
integration: true
|
|
|
|
},
|
|
|
|
function () {
|
|
|
|
it('trims value on focusOut', function () {
|
|
|
|
this.set('text', 'some random stuff ');
|
|
|
|
this.render(hbs`{{gh-trim-focus-input text update=(action (mut text))}}`);
|
|
|
|
|
|
|
|
run(() => {
|
|
|
|
this.$('.gh-input').trigger('focusout');
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(this.get('text')).to.equal('some random stuff');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not have the autofocus attribute if not set to focus', function () {
|
|
|
|
this.set('text', 'some text');
|
2016-06-20 17:20:25 +03:00
|
|
|
this.render(hbs`{{gh-trim-focus-input text shouldFocus=false}}`);
|
2016-06-18 14:44:23 +03:00
|
|
|
expect(this.$('.gh-input').attr('autofocus')).to.not.be.ok;
|
|
|
|
});
|
|
|
|
|
|
|
|
it('has the autofocus attribute if set to focus', function () {
|
|
|
|
this.set('text', 'some text');
|
2016-06-20 17:20:25 +03:00
|
|
|
this.render(hbs`{{gh-trim-focus-input text shouldFocus=true}}`);
|
2016-06-18 14:44:23 +03:00
|
|
|
expect(this.$('.gh-input').attr('autofocus')).to.be.ok;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|