Created
December 25, 2018 06:13
-
-
Save leejh3224/f8cb80bbcbb85a5a2abc2d8b78319349 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it("should test `onUserCreate`", async () => { | |
const wrapped = testEnv.wrap(api.onUserCreate); | |
const testUser = { | |
uid: "122", | |
displayName: "lee" | |
}; | |
await wrapped(testUser); | |
// generate user returns newUser object below | |
/* | |
const newUser = { | |
uid, | |
displayName, | |
points: 0, | |
questType: "view", // enum { view, sub } | |
questGoal: 30, | |
questActual: 10, | |
// valid for next 24 hours | |
questValidUntil: Date.now() + dayInMs | |
}; | |
*/ | |
const newUser = generateNewUser(testUser); | |
// check our db set function is called with expected parameter | |
expect(admin.database().ref(`/users/${testUser.uid}`).set).toBeCalledWith(newUser); | |
// check it returns mocked value as expected | |
expect(wrapped(testUser)).toBe(true); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment