Fakultas Ilmu Komputer UI

Commit 2172a38c authored by Josh Sudung's avatar Josh Sudung
Browse files

[REFACTOR] Refactor Loginpage test

parent f2a50191
Pipeline #44064 passed with stage
in 26 minutes and 48 seconds
......@@ -159,4 +159,51 @@ it('press signup button', async () => {
act(() => {
signup.props.onPress();
})
});
it('inserts invalid (length<8) password', async () => {
LocalStorage.setSecretKey('sssttt');
const instance = ReactTestRenderer.create(
<AppContext.Provider value={testProps}>
<NavigationContainer>
<Stack.Navigator
screenOptions={{
header: () => <></>,
}}>
<Stack.Screen name="login" component={LoginPage} />
</Stack.Navigator>
</NavigationContainer>
</AppContext.Provider>,
);
expect(instance.toJSON()).toMatchSnapshot();
const usernameField = instance.root.find(
elem => elem.props.id === 'username',
);
expect(usernameField).toBeTruthy();
const passwordField = instance.root.find(
elem => elem.props.id === 'password',
);
expect(passwordField).toBeTruthy();
act(() => {
if (usernameField && passwordField) {
usernameField.props.updateValue('user4x1d');
passwordField.props.updateValue('len3');
}
});
const submit = instance.root.find(elem => elem.props.id === 'submit');
await act(async () => {
submit.props.onPress();
});
const errorModal = instance.root.find(
elem => elem.props.id === 'error-modal',
);
expect(errorModal.props.visible).toBe(true);
});
\ No newline at end of file
......@@ -50,6 +50,7 @@ const LoginPage = () => {
</ModalContainer>
</Modal>
<Modal
id="error-modal"
animationType="fade"
transparent={true}
visible={errorModalVisible}
......
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