[FIX] Fix wizard spec

This commit introduces a mutation on input value given to select-box-kit when value is empty. The refactoring required to avoid this would be too heavy atm, but ultimately we would want to avoid this.
This commit is contained in:
Joffrey JAFFEUX 2017-10-19 17:34:56 -07:00 committed by GitHub
parent 24e3e321e1
commit 4d041d5b87
3 changed files with 26 additions and 2 deletions

View File

@ -56,6 +56,13 @@ export default Ember.Component.extend(UtilsMixin, DomHelpersMixin, KeyboardMixin
this.setProperties({ filterable: false, autoFilterable: false });
}
if (isNone(this.get("none")) && isEmpty(this.get("value")) && !isEmpty(this.get("content"))) {
Ember.run.scheduleOnce("sync", () => {
const firstValue = this.get(`content.0.${this.get("valueAttribute")}`);
this.set("value", firstValue);
});
}
this._previousScrollParentOverflow = "auto";
},

View File

@ -1,7 +1,7 @@
// import { componentTest } from 'wizard/test/helpers/component-test';
import { componentTest } from 'wizard/test/helpers/component-test';
moduleForComponent('invite-list', { integration: true });
QUnit.skip('can add users', {
componentTest('can add users', {
template: `{{invite-list field=field}}`,
beforeEach() {

View File

@ -222,3 +222,20 @@ componentTest('with no value and no none', {
// andThen(() => assert.equal(selectBox().rows.length, 1) );
// }
// });
componentTest('with empty string as value', {
template: '{{combo-box content=items value=value}}',
beforeEach() {
this.set('items', ['evil', 'trout', 'hat']);
this.set('value', '');
},
test(assert) {
expandSelectBox('.combobox');
andThen(() => {
assert.equal(selectBox('.combobox').header.name(), 'evil', 'it sets the first row as value');
});
}
});