2018-06-15 23:03:24 +08:00
|
|
|
import userSearch from "discourse/lib/user-search";
|
2016-10-24 09:43:38 +08:00
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
QUnit.module("lib:user-search", {
|
|
|
|
beforeEach() {
|
2018-06-15 23:03:24 +08:00
|
|
|
const response = object => {
|
|
|
|
return [200, { "Content-Type": "application/json" }, object];
|
2016-10-24 12:17:17 +08:00
|
|
|
};
|
|
|
|
|
2018-06-16 00:18:45 +08:00
|
|
|
// prettier-ignore
|
|
|
|
server.get("/u/search/users", () => { //eslint-disable-line
|
2018-06-15 23:03:24 +08:00
|
|
|
return response({
|
|
|
|
users: [
|
|
|
|
{
|
|
|
|
username: "TeaMoe",
|
|
|
|
name: "TeaMoe",
|
|
|
|
avatar_template:
|
|
|
|
"https://avatars.discourse.org/v3/letter/t/41988e/{size}.png"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
username: "TeamOneJ",
|
|
|
|
name: "J Cobb",
|
|
|
|
avatar_template:
|
2016-10-24 12:17:17 +08:00
|
|
|
"https://avatars.discourse.org/v3/letter/t/3d9bf3/{size}.png"
|
2018-06-15 23:03:24 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
username: "kudos",
|
|
|
|
name: "Team Blogeto.com",
|
|
|
|
avatar_template:
|
|
|
|
"/user_avatar/meta.discourse.org/kudos/{size}/62185_1.png"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
username: "RosieLinda",
|
|
|
|
name: "Linda Teaman",
|
|
|
|
avatar_template:
|
|
|
|
"https://avatars.discourse.org/v3/letter/r/bc8723/{size}.png"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
username: "legalatom",
|
|
|
|
name: "Team LegalAtom",
|
|
|
|
avatar_template:
|
|
|
|
"https://avatars.discourse.org/v3/letter/l/a9a28c/{size}.png"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
username: "dzsat_team",
|
|
|
|
name: "Dz Sat Dz Sat",
|
|
|
|
avatar_template:
|
|
|
|
"https://avatars.discourse.org/v3/letter/d/eb9ed0/{size}.png"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
groups: [
|
|
|
|
{
|
|
|
|
name: "bob",
|
|
|
|
usernames: []
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "team",
|
|
|
|
usernames: []
|
|
|
|
}
|
|
|
|
]
|
|
|
|
});
|
2016-10-24 12:17:17 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2016-10-24 09:43:38 +08:00
|
|
|
|
2018-05-17 15:17:58 +08:00
|
|
|
QUnit.test("it places groups unconditionally for exact match", async assert => {
|
2018-06-15 23:03:24 +08:00
|
|
|
let results = await userSearch({ term: "Team" });
|
|
|
|
assert.equal(results[results.length - 1]["name"], "team");
|
2018-02-13 10:28:29 +08:00
|
|
|
});
|