discourse/test/javascripts/components/list-setting-test.js.es6

91 lines
2.0 KiB
Plaintext
Raw Normal View History

2017-11-10 02:57:53 +08:00
import componentTest from 'helpers/component-test';
moduleForComponent('list-setting', {integration: true});
componentTest('default', {
template: '{{list-setting settingValue=settingValue choices=choices}}',
beforeEach() {
this.set('settingValue', 'bold|italic');
this.set('choices', ['bold', 'italic', 'underline']);
},
test(assert) {
expandSelectKit();
2017-11-10 02:57:53 +08:00
andThen(() => {
assert.propEqual(selectKit().header.name(), 'bold,italic');
});
}
});
componentTest('with emptry string as value', {
template: '{{list-setting settingValue=settingValue}}',
beforeEach() {
this.set('settingValue', '');
},
test(assert) {
expandSelectKit();
andThen(() => {
assert.equal(selectKit().header.el.find(".selected-name").length, 0);
2017-11-10 02:57:53 +08:00
});
}
});
componentTest('with only setting value', {
template: '{{list-setting settingValue=settingValue}}',
beforeEach() {
this.set('settingValue', 'bold|italic');
},
test(assert) {
expandSelectKit();
2017-11-10 02:57:53 +08:00
andThen(() => {
assert.propEqual(selectKit().header.name(), 'bold,italic');
2017-11-10 02:57:53 +08:00
});
}
});
componentTest('interactions', {
template: '{{list-setting settingValue=settingValue choices=choices}}',
beforeEach() {
this.set('settingValue', 'bold|italic');
this.set('choices', ['bold', 'italic', 'underline']);
},
test(assert) {
expandSelectKit();
2017-11-10 02:57:53 +08:00
selectKitSelectRow('underline');
2017-11-10 02:57:53 +08:00
andThen(() => {
assert.propEqual(selectKit().header.name(), 'bold,italic,underline');
2017-11-10 02:57:53 +08:00
});
selectKitFillInFilter('strike');
2017-11-10 02:57:53 +08:00
andThen(() => {
assert.equal(selectKit().highlightedRow.name(), 'strike');
2017-11-10 02:57:53 +08:00
});
selectKit().keyboard.enter();
2017-11-10 02:57:53 +08:00
andThen(() => {
assert.propEqual(selectKit().header.name(), 'bold,italic,underline,strike');
2017-11-10 02:57:53 +08:00
});
selectKit().keyboard.backspace();
selectKit().keyboard.backspace();
2017-11-10 02:57:53 +08:00
andThen(() => {
assert.equal(this.get('choices').length, 3, 'it removes the created content from original list');
});
}
});