Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ppl-fasilkom-ui
PPL Sosial
tbcare
tbcare-mobile
Commits
66b3266b
Commit
66b3266b
authored
Jun 03, 2021
by
Zafir Rasyidi Taufik
Browse files
[RED] Update test to include initial signout
parent
9ca4d2c0
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/scenes/LoginPage/index.test.tsx
View file @
66b3266b
...
...
@@ -272,8 +272,13 @@ it('goes to home if google sign in token already has corresponding user', async
resolve
(
data
);
}));
const
mockSignout
=
jest
.
fn
().
mockImplementationOnce
(()
=>
new
Promise
(
resolve
=>
{
resolve
(
true
);
}));
GoogleSignin
.
hasPlayServices
=
mockHasPlayServices
GoogleSignin
.
signIn
=
mockSignin
GoogleSignin
.
signOut
=
mockSignout
mockedAxios
.
request
.
mockImplementationOnce
(
()
=>
new
Promise
(
resolve
=>
{
...
...
@@ -291,6 +296,7 @@ it('goes to home if google sign in token already has corresponding user', async
googleSignin
.
props
.
onPress
();
})
await
expect
(
mockSignout
).
toBeCalledTimes
(
1
);
await
expect
(
mockHasPlayServices
).
toBeCalledTimes
(
1
);
await
expect
(
mockSignin
).
toBeCalledTimes
(
1
);
...
...
@@ -322,14 +328,20 @@ it('receives nothing when signin failed and fails to navigate to next scene', as
throw
new
Error
(
"
signin error
"
);
});
const
mockSignout
=
jest
.
fn
().
mockImplementationOnce
(()
=>
new
Promise
(
resolve
=>
{
resolve
(
true
);
}));
GoogleSignin
.
hasPlayServices
=
mockHasPlayServices
GoogleSignin
.
signIn
=
mockSignin
GoogleSignin
.
signOut
=
mockSignout
const
googleSignin
=
instance
.
root
.
findByType
(
GoogleSigninButton
);
act
(()
=>
{
googleSignin
.
props
.
onPress
();
})
await
expect
(
mockSignout
).
toBeCalledTimes
(
1
);
await
expect
(
mockHasPlayServices
).
toBeCalledTimes
(
1
);
await
expect
(
mockSignin
).
toBeCalledTimes
(
1
);
await
expect
(
mockNavigation
).
toBeCalledTimes
(
0
);
...
...
@@ -374,14 +386,20 @@ it('receives nothing when has no play service failed and fails to navigate to ne
resolve
(
data
);
}));
const
mockSignout
=
jest
.
fn
().
mockImplementationOnce
(()
=>
new
Promise
(
resolve
=>
{
resolve
(
true
);
}));
GoogleSignin
.
hasPlayServices
=
mockHasPlayServices
GoogleSignin
.
signIn
=
mockSignin
GoogleSignin
.
signOut
=
mockSignout
const
googleSignin
=
instance
.
root
.
findByType
(
GoogleSigninButton
);
act
(()
=>
{
googleSignin
.
props
.
onPress
();
})
await
expect
(
mockSignout
).
toBeCalledTimes
(
1
);
await
expect
(
mockHasPlayServices
).
toBeCalledTimes
(
1
);
await
expect
(
mockSignin
).
toBeCalledTimes
(
0
);
await
expect
(
mockNavigation
).
toBeCalledTimes
(
0
);
...
...
@@ -426,8 +444,13 @@ it('receives google token when signin is successful and succesfully navigates to
resolve
(
data
);
}));
const
mockSignout
=
jest
.
fn
().
mockImplementationOnce
(()
=>
new
Promise
(
resolve
=>
{
resolve
(
true
);
}));
GoogleSignin
.
hasPlayServices
=
mockHasPlayServices
GoogleSignin
.
signIn
=
mockSignin
GoogleSignin
.
signOut
=
mockSignout
mockedAxios
.
request
.
mockImplementationOnce
(
()
=>
new
Promise
(
resolve
=>
{
...
...
@@ -442,6 +465,7 @@ it('receives google token when signin is successful and succesfully navigates to
googleSignin
.
props
.
onPress
();
})
await
expect
(
mockSignout
).
toBeCalledTimes
(
1
);
await
expect
(
mockHasPlayServices
).
toBeCalledTimes
(
1
);
await
expect
(
mockSignin
).
toBeCalledTimes
(
1
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment