Skip to content

Commit 73f4c2c

Browse files
committed
Update Jest assertions to use toHaveBeenCalled instead of toBeCalled
1 parent 40b54df commit 73f4c2c

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

react-typescript-vite/src/tests/LoginForm.test.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,16 @@ describe('LoginForm', () => {
4646
await $username.setValue(username)
4747
await $password.setValue(password)
4848
await $btnLogin.click()
49-
expect(onLogin).toBeCalledTimes(1)
50-
expect(onLogin).toBeCalledWith({ username, password })
49+
expect(onLogin).toHaveBeenCalledTimes(1)
50+
expect(onLogin).toHaveBeenCalledWith({ username, password })
5151
})
5252

5353
it('should call onLogin with username and password when enter is pressed in an input', async () => {
5454
await $username.setValue(username)
5555
await $password.setValue(password)
5656
await browser.keys(Key.Enter)
57-
expect(onLogin).toBeCalledTimes(1)
58-
expect(onLogin).toBeCalledWith({ username, password })
57+
expect(onLogin).toHaveBeenCalledTimes(1)
58+
expect(onLogin).toHaveBeenCalledWith({ username, password })
5959
})
6060

6161
it('should show both validation errors if login is attempted without entering username or password', async () => {
@@ -66,7 +66,7 @@ describe('LoginForm', () => {
6666
await expect($form).toHaveText(
6767
expect.stringContaining('Password is required')
6868
)
69-
expect(onLogin).toBeCalledTimes(0)
69+
expect(onLogin).toHaveBeenCalledTimes(0)
7070
})
7171

7272
it('should only show password validation error if login is attempted without entering password', async () => {
@@ -78,7 +78,7 @@ describe('LoginForm', () => {
7878
await expect($form).toHaveText(
7979
expect.stringContaining('Password is required')
8080
)
81-
expect(onLogin).toBeCalledTimes(0)
81+
expect(onLogin).toHaveBeenCalledTimes(0)
8282
})
8383

8484
it('should only show username validation error if login is attempted without entering username', async () => {
@@ -90,7 +90,7 @@ describe('LoginForm', () => {
9090
await expect($form).not.toHaveText(
9191
expect.stringContaining('Password is required')
9292
)
93-
expect(onLogin).toBeCalledTimes(0)
93+
expect(onLogin).toHaveBeenCalledTimes(0)
9494
})
9595

9696
it('should not show any validation errors before login is attempted', async () => {

0 commit comments

Comments
 (0)