Skip to content

Commit 24fb190

Browse files
add tests for returning discord users
1 parent 1f8861b commit 24fb190

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

test/fixtures/user/inDiscord.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
module.exports = () => {
2+
return [
3+
{
4+
discordId: "1234567890987543",
5+
first_name: "jhon",
6+
last_name: "doe",
7+
username: "jhon-doe",
8+
github_id: "jhon-doe",
9+
github_display_name: "jhon-doe",
10+
incompleteUserDetails: false,
11+
roles: {
12+
archived: false,
13+
in_discord: true,
14+
},
15+
tokens: {
16+
githubAccessToken: "weuytrertyuiiuyrtyui4567yyyuyghy",
17+
},
18+
},
19+
{
20+
discordId: "8494597689576953",
21+
first_name: "test",
22+
last_name: "user",
23+
username: "test-user",
24+
github_id: "test-user",
25+
github_display_name: "test-user",
26+
incompleteUserDetails: false,
27+
roles: {
28+
archived: false,
29+
in_discord: false,
30+
},
31+
tokens: {
32+
githubAccessToken: "weuytrertyuiiuyrtyui4567yyyuyghy",
33+
},
34+
},
35+
{
36+
first_name: "test",
37+
last_name: "user",
38+
username: "test-user",
39+
github_id: "test-user",
40+
github_display_name: "test-user",
41+
incompleteUserDetails: false,
42+
roles: {
43+
archived: false,
44+
in_discord: false,
45+
},
46+
tokens: {
47+
githubAccessToken: "weuytrertyuiiuyrtyui4567yyyuyghy",
48+
},
49+
},
50+
];
51+
};

test/integration/users.test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const userData = require("../fixtures/user/user")();
1313
const profileDiffData = require("../fixtures/profileDiffs/profileDiffs")();
1414
const superUser = userData[4];
1515
const searchParamValues = require("../fixtures/user/search")();
16+
const inDiscordUsers = require("../fixtures/user/inDiscord")();
1617

1718
const config = require("config");
1819
const joinData = require("../fixtures/user/join");
@@ -1071,4 +1072,27 @@ describe("Users", function () {
10711072
});
10721073
});
10731074
});
1075+
1076+
describe("PATCH /users", function () {
1077+
beforeEach(async function () {
1078+
await addUser(inDiscordUsers[0]);
1079+
await addUser(inDiscordUsers[1]);
1080+
await addUser(inDiscordUsers[2]);
1081+
});
1082+
it("returns users with discord id and in_discord false", function (done) {
1083+
chai
1084+
.request(app)
1085+
.patch("/users")
1086+
.set("Cookie", `${cookieName}=${jwt}`)
1087+
.end((err, res) => {
1088+
if (err) {
1089+
return done(err);
1090+
}
1091+
expect(res).to.have.status(200);
1092+
expect(res.body).to.have.length(1);
1093+
expect(res.body[0].username).equal("test-user");
1094+
return done();
1095+
});
1096+
});
1097+
});
10741098
});

0 commit comments

Comments
 (0)