Skip to content

Commit f2f755c

Browse files
Added test for id filterin in addOrUpdate
1 parent 2c4438a commit f2f755c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test/unit/models/users.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ describe("users", function () {
114114
const { user } = await users.fetchUser({ githubUsername });
115115
expect(user).to.haveOwnProperty("github_created_at");
116116
});
117+
118+
it("it should filter out the id field while updating profileDiff", async function () {
119+
const userData = userDataArray[0];
120+
const { userId } = await users.addOrUpdate(userData);
121+
const profileDiff = { id: "random-id", diff: "random-diff" };
122+
await users.addOrUpdate(profileDiff, userId);
123+
const data = (await userModel.doc(userId).get()).data();
124+
expect(data).to.haveOwnProperty("diff"); // Ensures profile diffs are pushed
125+
expect(data.id).not.equal("random-id"); // Ensures id is not added / updated by profile Diffs
126+
});
117127
});
118128

119129
describe("fetch user details based on discord id", function () {

0 commit comments

Comments
 (0)