ok(!controller.get("loading"), "loading flag is false");
ok(!controller.get("noResults"), "noResults flag is false");
deepEqual(controller.get("content"), [], "content is empty");
equal(controller.get("selectedIndex"), 0, "selectedIndex is set to 0");
equal(controller.get("resultCount"), 0, "result count is set to 0");
});
test("when user typed a search term that is equal to or exceeds the minimum character count threshold, but results have not yet finished loading", function() {
ok(controller.get("loading"), "loading flag is true");
ok(!controller.get("noResults"), "noResults flag is false");
deepEqual(controller.get("content"), [], "content is empty");
equal(controller.get("selectedIndex"), 0, "selectedIndex is set to 0");
equal(controller.get("resultCount"), 0, "result count is set to 0");
});
test("when user typed a search term that is equal to or exceeds the minimum character count threshold and results have finished loading, but there are no results found", function() {
ok(!controller.get("loading"), "loading flag is false");
ok(controller.get("noResults"), "noResults flag is true");
deepEqual(controller.get("content"), [], "content is empty");
equal(controller.get("selectedIndex"), 0, "selectedIndex is set to 0");
equal(controller.get("resultCount"), 0, "result count is set to 0");
});
test("when user typed a search term that is equal to or exceeds the minimum character count threshold and results have finished loading, and there are results found", function() {
ok(!controller.get("loading"), "loading flag is reset correctly");
ok(!controller.get("noResults"), "noResults flag is reset correctly");
deepEqual(controller.get("content"), [], "content is reset correctly");
equal(controller.get("selectedIndex"), 0, "selected index is reset correctly");
equal(controller.get("resultCount"), 0, "resultCount is reset correctly");
});
test("search results from the server are correctly reformatted (sections are sorted, section fields are preserved, item sorting is preserved, item fields are preserved, items are globally indexed across all sections)", function() {
), "when an initial search (with term but without a type filter) is issued, query is built correctly and results are refreshed");
ok(!controller.get("showCancelFilter"), "when an initial search (with term but without a type filter) is issued, showCancelFilter flag is false");
Discourse.Search.forTerm.reset();
Ember.run(function() {
controller.send("moreOfType", "topic");
});
ok(Discourse.Search.forTerm.calledWithExactly(
"ab",
{
searchContext: "context",
typeFilter: "topic"
}
), "when after the initial search a type filter is applied (moreOfType action is invoked), query is built correctly and results are refreshed");
ok(!controller.get("showCancelFilter"), "when after the initial search a type filter is applied (moreOfType action is invoked) but the results did not yet finished loading, showCancelFilter flag is still false");
Ember.run(function() {
searcherStub.resolve([]);
});
ok(controller.get("showCancelFilter"), "when after the initial search a type filter is applied (moreOfType action is invoked) and the results finished loading, showCancelFilter flag is set to true");
Discourse.Search.forTerm.reset();
Ember.run(function() {
controller.send("cancelType");
});
ok(Discourse.Search.forTerm.calledWithExactly(
"ab",
{
searchContext: "context",
typeFilter: null
}
), "when cancelType action is invoked after the results were filtered by type, query is built correctly and results are refreshed");
ok(!controller.get("showCancelFilter"), "when cancelType action is invoked after the results were filtered by type, showCancelFilter flag is set to false");
});
test("typing new term when the results are filtered by type cancels type filter", function() {