2016-10-23 21:43:38 -04:00
|
|
|
import userSearch from 'discourse/lib/user-search';
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.module("lib:user-search", {
|
|
|
|
beforeEach() {
|
2016-10-24 00:17:17 -04:00
|
|
|
const response = (object) => {
|
|
|
|
return [
|
|
|
|
200,
|
|
|
|
{"Content-Type": "application/json"},
|
|
|
|
object
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2017-03-28 12:16:58 -04:00
|
|
|
server.get('/u/search/users', () => { //eslint-disable-line
|
2016-10-24 00:17:17 -04: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":
|
|
|
|
"https://avatars.discourse.org/v3/letter/t/3d9bf3/{size}.png"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"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": "team",
|
|
|
|
"usernames": []
|
|
|
|
}
|
|
|
|
]
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2016-10-23 21:43:38 -04:00
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("it places groups unconditionally for exact match", assert => {
|
2017-05-01 14:37:16 -04:00
|
|
|
return userSearch({term: 'Team'}).then((results)=>{
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.equal(results[results.length-1]["name"], "team");
|
2016-10-23 21:43:38 -04:00
|
|
|
});
|
2017-06-14 13:57:58 -04:00
|
|
|
});
|