Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit 1ee33ed

Browse files
committed
Init pin views when navigating back during pin reset
1 parent f5db956 commit 1ee33ed

File tree

6 files changed

+40
-18
lines changed

6 files changed

+40
-18
lines changed

src/action/auth-mobile.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@ class AuthAction {
5555
this._nav.goResetPasswordCurrent();
5656
}
5757

58+
/**
59+
* Initialize the reset new pin flow by resetting new values
60+
* and then navigating to the new pin view.
61+
* @return {undefined}
62+
*/
63+
initResetPinNew() {
64+
this._store.auth.resetPinNew = '';
65+
this._store.auth.resetPinVerify = '';
66+
this._nav.goResetPasswordNew();
67+
}
68+
5869
/**
5970
* Append a digit input to the pin parameter.
6071
* @param {string} options.digit The digit to append to the pin
@@ -100,8 +111,7 @@ class AuthAction {
100111
} else if (param === 'resetPinNew') {
101112
this.initResetPin();
102113
} else if (param === 'resetPinVerify') {
103-
this._store.auth.resetPinNew = '';
104-
this._nav.goResetPasswordNew();
114+
this.initResetPinNew();
105115
}
106116
}
107117

src/view/main-mobile.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,10 @@ const ResetPasswordCurrent = () => (
101101
<ResetPinCurrentView store={store} auth={auth} nav={nav} />
102102
);
103103

104-
const ResetPasswordNew = () => (
105-
<ResetPinNewView store={store} auth={auth} nav={nav} />
106-
);
104+
const ResetPasswordNew = () => <ResetPinNewView store={store} auth={auth} />;
107105

108106
const ResetPasswordConfirm = () => (
109-
<ResetPinConfirmView store={store} auth={auth} nav={nav} />
107+
<ResetPinConfirmView store={store} auth={auth} />
110108
);
111109

112110
const ResetPasswordSaved = () => <ResetPinSavedView nav={nav} />;

src/view/reset-pin-confirm-mobile.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ const styles = StyleSheet.create({
3030
},
3131
});
3232

33-
const ResetPinConfirmView = ({ store, nav, auth }) => (
33+
const ResetPinConfirmView = ({ store, auth }) => (
3434
<Background color={color.blackDark}>
3535
<Header separator>
36-
<BackButton onPress={() => nav.goResetPasswordNew()} />
36+
<BackButton onPress={() => auth.initResetPinNew()} />
3737
<Title title="Change PIN" />
3838
<Button disabled onPress={() => {}} />
3939
</Header>
@@ -56,7 +56,6 @@ const ResetPinConfirmView = ({ store, nav, auth }) => (
5656
ResetPinConfirmView.propTypes = {
5757
store: PropTypes.object.isRequired,
5858
auth: PropTypes.object.isRequired,
59-
nav: PropTypes.object.isRequired,
6059
};
6160

6261
export default observer(ResetPinConfirmView);

src/view/reset-pin-new-mobile.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ const styles = StyleSheet.create({
3030
},
3131
});
3232

33-
const NewPinView = ({ store, nav, auth }) => (
33+
const ResetPinNewView = ({ store, auth }) => (
3434
<Background color={color.blackDark}>
3535
<Header separator>
36-
<BackButton onPress={() => nav.goResetPasswordCurrent()} />
36+
<BackButton onPress={() => auth.initResetPin()} />
3737
<Title title="Change PIN" />
3838
<Button disabled onPress={() => {}} />
3939
</Header>
@@ -53,10 +53,9 @@ const NewPinView = ({ store, nav, auth }) => (
5353
</Background>
5454
);
5555

56-
NewPinView.propTypes = {
56+
ResetPinNewView.propTypes = {
5757
store: PropTypes.object.isRequired,
5858
auth: PropTypes.object.isRequired,
59-
nav: PropTypes.object.isRequired,
6059
};
6160

62-
export default observer(NewPinView);
61+
export default observer(ResetPinNewView);

stories/screen-story.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,10 @@ storiesOf('Screens', module)
176176
<ResetPinCurrent store={store} auth={auth} nav={nav} />
177177
))
178178
.add('Reset PIN - New (Mobile)', () => (
179-
<ResetPinNew store={store} auth={auth} nav={nav} />
179+
<ResetPinNew store={store} auth={auth} />
180180
))
181181
.add('Reset PIN - Confirm New (Mobile)', () => (
182-
<ResetPinConfirm store={store} auth={auth} nav={nav} />
182+
<ResetPinConfirm store={store} auth={auth} />
183183
))
184184
.add('Reset PIN - Saved (Mobile)', () => <ResetPinSaved nav={nav} />)
185185
.add('New Address', () => (

test/unit/action/auth-mobile.spec.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ describe('Action AuthMobile Unit Tests', () => {
6464
});
6565
});
6666

67+
describe('initResetPinNew()', () => {
68+
it('should init values and navigate', () => {
69+
store.auth.resetPinCurrent = '123456';
70+
auth.initResetPinNew();
71+
expect(store.auth.resetPinCurrent, 'to equal', '123456');
72+
expect(store.auth.resetPinNew, 'to equal', '');
73+
expect(store.auth.resetPinVerify, 'to equal', '');
74+
expect(nav.goResetPasswordNew, 'was called once');
75+
});
76+
});
77+
6778
describe('pushPinDigit()', () => {
6879
it('should add a digit for empty pin', () => {
6980
auth.pushPinDigit({ digit: '1', param: 'pin' });
@@ -104,6 +115,11 @@ describe('Action AuthMobile Unit Tests', () => {
104115
});
105116

106117
describe('popPinDigit()', () => {
118+
beforeEach(() => {
119+
sandbox.stub(auth, 'initResetPinNew');
120+
sandbox.stub(auth, 'initResetPin');
121+
});
122+
107123
it('should remove digit from a pin', () => {
108124
store.auth.pin = '000000';
109125
auth.popPinDigit({ param: 'pin' });
@@ -131,13 +147,13 @@ describe('Action AuthMobile Unit Tests', () => {
131147
it('should go from ResetPinConfirmed to ResetPinNew on empty string', () => {
132148
store.auth.resetPinVerify = '';
133149
auth.popPinDigit({ param: 'resetPinVerify' });
134-
expect(nav.goResetPasswordNew, 'was called once');
150+
expect(auth.initResetPinNew, 'was called once');
135151
});
136152

137153
it('should go from ResetPinNew to ResetPinCurrent on empty string', () => {
138154
store.auth.resetPinNew = '';
139155
auth.popPinDigit({ param: 'resetPinNew' });
140-
expect(nav.goResetPasswordCurrent, 'was called once');
156+
expect(auth.initResetPin, 'was called once');
141157
});
142158
});
143159

0 commit comments

Comments
 (0)