FEATURE: New "Dropdown" user field type

This commit is contained in:
Robin Ward
2015-07-28 12:29:40 -04:00
parent f22618050f
commit dc8a68fd29
18 changed files with 248 additions and 52 deletions

View File

@ -0,0 +1,45 @@
import componentTest from 'helpers/component-test';
moduleForComponent('combo-box', {integration: true});
componentTest('with objects', {
template: '{{combo-box content=items value=value}}',
setup() {
this.set('items', [{id: 1, name: 'hello'}, {id: 2, name: 'world'}]);
},
test(assert) {
assert.equal(this.get('value'), 1);
assert.ok(this.$('.combobox').length);
assert.equal(this.$("select option[value='1']").text(), 'hello');
assert.equal(this.$("select option[value='2']").text(), 'world');
}
});
componentTest('with an array', {
template: '{{combo-box content=items value=value}}',
setup() {
this.set('items', ['evil', 'trout', 'hat']);
},
test(assert) {
assert.equal(this.get('value'), 'evil');
assert.ok(this.$('.combobox').length);
assert.equal(this.$("select option[value='evil']").text(), 'evil');
assert.equal(this.$("select option[value='trout']").text(), 'trout');
}
});
componentTest('with none', {
template: '{{combo-box content=items none="test.none" value=value}}',
setup() {
I18n.translations[I18n.locale].js.test = {none: 'none'};
this.set('items', ['evil', 'trout', 'hat']);
},
test(assert) {
assert.equal(this.$("select option:eq(0)").text(), 'none');
assert.equal(this.$("select option:eq(0)").val(), '');
assert.equal(this.$("select option:eq(1)").text(), 'evil');
assert.equal(this.$("select option:eq(2)").text(), 'trout');
}
});