mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
add tag-drop component test
This commit is contained in:
parent
0a2efd8ff1
commit
03edb31a4d
71
test/javascripts/components/tag-drop-test.js.es6
Normal file
71
test/javascripts/components/tag-drop-test.js.es6
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
import componentTest from "helpers/component-test";
|
||||||
|
|
||||||
|
moduleForComponent("tag-drop", {
|
||||||
|
integration: true,
|
||||||
|
beforeEach: function() {
|
||||||
|
this.set("subject", selectKit());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
componentTest("default", {
|
||||||
|
template: "{{tag-drop}}",
|
||||||
|
|
||||||
|
beforeEach() {
|
||||||
|
this.site.set("can_create_tag", true);
|
||||||
|
this.set("site.top_tags", ["jeff", "neil", "arpit", "régis"]);
|
||||||
|
|
||||||
|
const response = object => {
|
||||||
|
return [200, { "Content-Type": "application/json" }, object];
|
||||||
|
};
|
||||||
|
|
||||||
|
// prettier-ignore
|
||||||
|
server.get("/tags/filter/search", (params) => { //eslint-disable-line
|
||||||
|
if (params.queryParams.q === "rég") {
|
||||||
|
return response({
|
||||||
|
"results": [
|
||||||
|
{ "id": "régis", "name": "régis", "count": 2, "pm_count": 0 }
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
async test(assert) {
|
||||||
|
await this.get("subject").expand();
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
this.get("subject")
|
||||||
|
.rowByIndex(0)
|
||||||
|
.name(),
|
||||||
|
"jeff",
|
||||||
|
"it has the correct tag"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
this.get("subject")
|
||||||
|
.rowByIndex(1)
|
||||||
|
.name(),
|
||||||
|
"neil",
|
||||||
|
"it has the correct tag"
|
||||||
|
);
|
||||||
|
|
||||||
|
await this.get("subject").fillInFilter("rég");
|
||||||
|
assert.equal(
|
||||||
|
this.get("subject")
|
||||||
|
.rowByIndex(0)
|
||||||
|
.name(),
|
||||||
|
"régis",
|
||||||
|
"it displays the searched tag"
|
||||||
|
);
|
||||||
|
|
||||||
|
await this.get("subject").fillInFilter("");
|
||||||
|
assert.equal(
|
||||||
|
this.get("subject")
|
||||||
|
.rowByIndex(0)
|
||||||
|
.name(),
|
||||||
|
"jeff",
|
||||||
|
"it returns top tags for an empty search"
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user