2017-10-20 03:51:08 +08:00
|
|
|
import componentTest from 'helpers/component-test';
|
|
|
|
|
|
|
|
moduleForComponent('category-chooser', {integration: true});
|
|
|
|
|
|
|
|
componentTest('with value', {
|
|
|
|
template: '{{category-chooser value=2}}',
|
|
|
|
|
|
|
|
test(assert) {
|
2017-11-21 18:53:09 +08:00
|
|
|
expandSelectKit();
|
2017-10-20 03:51:08 +08:00
|
|
|
|
|
|
|
andThen(() => {
|
2017-11-21 18:53:09 +08:00
|
|
|
assert.equal(selectKit('.category-chooser').header.name(), "feature");
|
2017-10-20 03:51:08 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
componentTest('with excludeCategoryId', {
|
|
|
|
template: '{{category-chooser excludeCategoryId=2}}',
|
|
|
|
|
|
|
|
test(assert) {
|
2017-11-21 18:53:09 +08:00
|
|
|
expandSelectKit();
|
2017-10-20 03:51:08 +08:00
|
|
|
|
|
|
|
andThen(() => {
|
2017-11-21 18:53:09 +08:00
|
|
|
assert.equal(selectKit('.category-chooser').rowByValue(2).el.length, 0);
|
2017-10-20 03:51:08 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
componentTest('with scopedCategoryId', {
|
|
|
|
template: '{{category-chooser scopedCategoryId=2}}',
|
|
|
|
|
|
|
|
test(assert) {
|
2017-11-21 18:53:09 +08:00
|
|
|
expandSelectKit();
|
2017-10-20 03:51:08 +08:00
|
|
|
|
|
|
|
andThen(() => {
|
2017-11-21 18:53:09 +08:00
|
|
|
assert.equal(selectKit('.category-chooser').rowByIndex(0).name(), "feature");
|
|
|
|
assert.equal(selectKit('.category-chooser').rowByIndex(1).name(), "spec");
|
|
|
|
assert.equal(selectKit('.category-chooser').el.find(".select-kit-row").length, 2);
|
2017-10-20 03:51:08 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
componentTest('with allowUncategorized=null', {
|
|
|
|
template: '{{category-chooser allowUncategorized=null}}',
|
|
|
|
|
|
|
|
beforeEach() {
|
|
|
|
this.siteSettings.allow_uncategorized_topics = false;
|
|
|
|
},
|
|
|
|
|
|
|
|
test(assert) {
|
2017-11-21 18:53:09 +08:00
|
|
|
expandSelectKit();
|
2017-10-20 03:51:08 +08:00
|
|
|
|
|
|
|
andThen(() => {
|
2017-11-21 18:53:09 +08:00
|
|
|
assert.equal(selectKit('.category-chooser').header.name(), "Select a category…");
|
2017-10-20 03:51:08 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
componentTest('with allowUncategorized=null rootNone=true', {
|
|
|
|
template: '{{category-chooser allowUncategorized=null rootNone=true}}',
|
|
|
|
|
|
|
|
beforeEach() {
|
|
|
|
this.siteSettings.allow_uncategorized_topics = false;
|
|
|
|
},
|
|
|
|
|
|
|
|
test(assert) {
|
2017-11-21 18:53:09 +08:00
|
|
|
expandSelectKit();
|
2017-10-20 03:51:08 +08:00
|
|
|
|
|
|
|
andThen(() => {
|
2017-11-21 18:53:09 +08:00
|
|
|
assert.equal(selectKit('.category-chooser').header.name(), "Select a category…");
|
2017-10-20 03:51:08 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
componentTest('with disallowed uncategorized, rootNone and rootNoneLabel', {
|
|
|
|
template: '{{category-chooser allowUncategorized=null rootNone=true rootNoneLabel="test.root"}}',
|
|
|
|
|
|
|
|
beforeEach() {
|
|
|
|
I18n.translations[I18n.locale].js.test = {root: 'root none label'};
|
|
|
|
this.siteSettings.allow_uncategorized_topics = false;
|
|
|
|
},
|
|
|
|
|
|
|
|
test(assert) {
|
2017-11-21 18:53:09 +08:00
|
|
|
expandSelectKit();
|
2017-10-20 03:51:08 +08:00
|
|
|
|
|
|
|
andThen(() => {
|
2017-11-21 18:53:09 +08:00
|
|
|
assert.equal(selectKit('.category-chooser').header.name(), "Select a category…");
|
2017-10-20 03:51:08 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
componentTest('with allowed uncategorized', {
|
|
|
|
template: '{{category-chooser allowUncategorized=true}}',
|
|
|
|
|
|
|
|
beforeEach() {
|
|
|
|
this.siteSettings.allow_uncategorized_topics = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
test(assert) {
|
2017-11-21 18:53:09 +08:00
|
|
|
expandSelectKit();
|
2017-10-20 03:51:08 +08:00
|
|
|
|
|
|
|
andThen(() => {
|
2017-11-21 18:53:09 +08:00
|
|
|
assert.equal(selectKit('.category-chooser').header.name(), "uncategorized");
|
2017-10-20 03:51:08 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
componentTest('with allowed uncategorized and rootNone', {
|
|
|
|
template: '{{category-chooser allowUncategorized=true rootNone=true}}',
|
|
|
|
|
|
|
|
beforeEach() {
|
|
|
|
this.siteSettings.allow_uncategorized_topics = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
test(assert) {
|
2017-11-21 18:53:09 +08:00
|
|
|
expandSelectKit();
|
2017-10-20 03:51:08 +08:00
|
|
|
|
|
|
|
andThen(() => {
|
2017-11-21 18:53:09 +08:00
|
|
|
assert.equal(selectKit('.category-chooser').header.name(), "(no category)");
|
2017-10-20 03:51:08 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
componentTest('with allowed uncategorized rootNone and rootNoneLabel', {
|
|
|
|
template: '{{category-chooser allowUncategorized=true rootNone=true rootNoneLabel="test.root"}}',
|
|
|
|
|
|
|
|
beforeEach() {
|
|
|
|
I18n.translations[I18n.locale].js.test = {root: 'root none label'};
|
|
|
|
this.siteSettings.allow_uncategorized_topics = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
test(assert) {
|
2017-11-21 18:53:09 +08:00
|
|
|
expandSelectKit();
|
2017-10-20 03:51:08 +08:00
|
|
|
|
|
|
|
andThen(() => {
|
2017-11-21 18:53:09 +08:00
|
|
|
assert.equal(selectKit('.category-chooser').header.name(), "root none label");
|
2017-10-20 03:51:08 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|