Fakultas Ilmu Komputer UI

Commit 66b3266b authored by Zafir Rasyidi Taufik's avatar Zafir Rasyidi Taufik
Browse files

[RED] Update test to include initial signout

parent 9ca4d2c0
......@@ -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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment