2015-07-14 13:56:59 -04:00
|
|
|
import componentTest from 'helpers/component-test';
|
2015-06-09 12:19:41 -04:00
|
|
|
moduleForComponent('value-list', {integration: true});
|
|
|
|
|
2015-07-14 13:56:59 -04:00
|
|
|
componentTest('functionality', {
|
2015-07-28 12:29:40 -04:00
|
|
|
template: '{{value-list values=values inputType="array"}}',
|
|
|
|
test(assert) {
|
|
|
|
assert.ok(this.$('.values .value').length === 0, 'it has no values');
|
|
|
|
assert.ok(this.$('input').length, 'it renders the input');
|
|
|
|
assert.ok(this.$('.btn-primary[disabled]').length, 'it is disabled with no value');
|
2015-06-09 12:19:41 -04:00
|
|
|
|
2015-07-14 13:56:59 -04:00
|
|
|
fillIn('input', 'eviltrout');
|
|
|
|
andThen(() => {
|
|
|
|
assert.ok(!this.$('.btn-primary[disabled]').length, "it isn't disabled anymore");
|
|
|
|
});
|
2015-06-09 12:19:41 -04:00
|
|
|
|
2015-07-14 13:56:59 -04:00
|
|
|
click('.btn-primary');
|
|
|
|
andThen(() => {
|
2015-07-28 12:29:40 -04:00
|
|
|
assert.equal(this.$('.values .value').length, 1, 'it adds the value');
|
|
|
|
assert.equal(this.$('input').val(), '', 'it clears the input');
|
2015-07-14 13:56:59 -04:00
|
|
|
assert.ok(this.$('.btn-primary[disabled]').length, "it is disabled again");
|
2015-07-28 12:29:40 -04:00
|
|
|
assert.equal(this.get('values'), 'eviltrout', 'it appends the value');
|
2015-07-14 13:56:59 -04:00
|
|
|
});
|
2015-06-09 12:19:41 -04:00
|
|
|
|
2015-07-14 13:56:59 -04:00
|
|
|
click('.value .btn-small');
|
|
|
|
andThen(() => {
|
|
|
|
assert.ok(this.$('.values .value').length === 0, 'it removes the value');
|
|
|
|
});
|
|
|
|
}
|
2015-06-09 12:19:41 -04:00
|
|
|
});
|
2015-07-28 12:29:40 -04:00
|
|
|
|
|
|
|
componentTest('with string delimited values', {
|
|
|
|
template: '{{value-list values=valueString}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2015-07-28 12:29:40 -04:00
|
|
|
this.set('valueString', "hello\nworld");
|
|
|
|
},
|
|
|
|
|
|
|
|
test(assert) {
|
|
|
|
assert.equal(this.$('.values .value').length, 2);
|
|
|
|
|
|
|
|
fillIn('input', 'eviltrout');
|
|
|
|
click('.btn-primary');
|
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
assert.equal(this.$('.values .value').length, 3);
|
|
|
|
assert.equal(this.get('valueString'), "hello\nworld\neviltrout");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
componentTest('with array values', {
|
|
|
|
template: '{{value-list values=valueArray inputType="array"}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2015-07-28 12:29:40 -04:00
|
|
|
this.set('valueArray', ['abc', 'def']);
|
|
|
|
},
|
|
|
|
|
|
|
|
test(assert) {
|
|
|
|
assert.equal(this.$('.values .value').length, 2);
|
|
|
|
|
|
|
|
fillIn('input', 'eviltrout');
|
|
|
|
click('.btn-primary');
|
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
assert.equal(this.$('.values .value').length, 3);
|
|
|
|
assert.deepEqual(this.get('valueArray'), ['abc', 'def', 'eviltrout']);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|