Last active
August 10, 2020 03:05
-
-
Save LarryLuTW/6fa596b4497d273bb300f1cf31e682b2 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
// Test Case 3 | |
test('若帳號密碼都沒問題則註冊成功,而且 db.createUser 一定要被呼叫', async () => { | |
// 把 isUserExist 跟 createUser 都替換掉,並要求 isUserExist 回傳 false | |
const stubIsUserExist = sinon.stub(db, 'isUserExist').returns(false) | |
const stubCreateUser = sinon.stub(db, 'createUser') | |
let user = { username: 'larry', password: 'pa55w0rd' } | |
// 確認註冊成功 | |
await expect(signup(user)).resolves.toBe() | |
// 確認 db.isUserExist 跟 db.createUser 都有被呼叫 | |
expect(stubIsUserExist.called).toBe(true) | |
expect(stubCreateUser.called).toBe(true) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment