forked from keybase/client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
56f7476
commit ca2ac8a
Showing
4 changed files
with
130 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,22 +18,23 @@ const makeTypedState = (signupState: Types.State): TypedState => ({signup: signu | |
|
||
describe('goBackAndClearErrors', () => { | ||
it('errors get cleaned and we go back a level', () => { | ||
const state = Constants.makeState({ | ||
const state = { | ||
...Constants.makeState(), | ||
devicenameError: 'bad name', | ||
emailError: 'bad email', | ||
inviteCodeError: 'bad invite', | ||
nameError: 'bad name', | ||
signupError: new RPCError('bad signup', 0), | ||
usernameError: 'bad username', | ||
}) | ||
} | ||
|
||
const action = SignupGen.createGoBackAndClearErrors() | ||
const nextState = {signup: reducer(state, action)} | ||
expect(nextState.signup.devicenameError).toEqual('') | ||
expect(nextState.signup.emailError).toEqual('') | ||
expect(nextState.signup.inviteCodeError).toEqual('') | ||
expect(nextState.signup.nameError).toEqual('') | ||
expect(nextState.signup.signupError).toEqual(null) | ||
expect(nextState.signup.signupError).toEqual(undefined) | ||
expect(nextState.signup.usernameError).toEqual('') | ||
expect(_testing.goBackAndClearErrors()).toEqual(RouteTreeGen.createNavigateUp()) | ||
}) | ||
|
@@ -68,7 +69,7 @@ describe('requestAutoInvite', () => { | |
|
||
describe('requestInvite', () => { | ||
it('ignores if theres an error', () => { | ||
const state = Constants.makeState({devicenameError: 'has an error'}) | ||
const state = {...Constants.makeState(), devicenameError: 'has an error'} | ||
const action = SignupGen.createRequestInvite({email: '[email protected]', name: 'name'}) | ||
const nextState = makeTypedState(reducer(state, action)) | ||
expect(_testing.showInviteSuccessOnNoErrors(nextState)).toEqual(false) | ||
|
@@ -161,7 +162,7 @@ describe('checkInviteCode', () => { | |
|
||
describe('checkUsername', () => { | ||
it("ignores if there's an error", () => { | ||
const state = Constants.makeState({inviteCodeError: 'invite error'}) | ||
const state = {...Constants.makeState(), inviteCodeError: 'invite error'} | ||
expect(_testing.checkUsername(makeTypedState(state), null as any, testLogger)).resolves.toEqual(false) | ||
}) | ||
|
||
|
@@ -183,7 +184,7 @@ describe('checkUsername', () => { | |
|
||
describe('checkedUsername', () => { | ||
it("ignores if username doesn't match", () => { | ||
const state = Constants.makeState({username: 'username'}) | ||
const state = {...Constants.makeState(), username: 'username'} | ||
const action = SignupGen.createCheckedUsername({ | ||
error: 'another problem', | ||
username: 'different username', | ||
|
@@ -194,7 +195,7 @@ describe('checkedUsername', () => { | |
}) | ||
|
||
it('shows error', () => { | ||
const state = Constants.makeState({username: 'username'}) | ||
const state = {...Constants.makeState(), username: 'username'} | ||
const action = SignupGen.createCheckedUsername({ | ||
error: 'another problem', | ||
username: state.username, | ||
|
@@ -204,7 +205,7 @@ describe('checkedUsername', () => { | |
}) | ||
|
||
it('shows device name page on success', () => { | ||
const state = Constants.makeState({username: 'username'}) | ||
const state = {...Constants.makeState(), username: 'username'} | ||
const action = SignupGen.createCheckedUsername({ | ||
error: '', | ||
username: state.username, | ||
|
@@ -265,15 +266,15 @@ describe('deviceScreen', () => { | |
}) | ||
|
||
it("ignores if devicename doesn't match", () => { | ||
const state = Constants.makeState({devicename: 'a device'}) | ||
const state = {...Constants.makeState(), devicename: 'a device'} | ||
const action = SignupGen.createCheckedDevicename({devicename: 'different name', error: 'an error'}) | ||
const nextState = makeTypedState(reducer(state, action)) | ||
// doesn't update | ||
expect(nextState).toEqual(makeTypedState(state)) | ||
}) | ||
|
||
it('shows error', () => { | ||
const state = Constants.makeState({devicename: 'devicename'}) | ||
const state = {...Constants.makeState(), devicename: 'devicename'} | ||
const action = SignupGen.createCheckedDevicename({devicename: 'devicename', error: 'an error'}) | ||
const nextState = makeTypedState(reducer(makeTypedState(state).signup, action)) | ||
expect(nextState.signup.devicename).toEqual(action.payload.devicename) | ||
|
@@ -283,51 +284,52 @@ describe('deviceScreen', () => { | |
|
||
describe('actually sign up', () => { | ||
it('bails on devicenameError', () => { | ||
const state = Constants.makeState({devicenameError: 'error'}) | ||
const state = {...Constants.makeState(), devicenameError: 'error'} | ||
expect(_testing.reallySignupOnNoErrors(makeTypedState(state)).next().value).toBeUndefined() | ||
}) | ||
it('bails on emailError', () => { | ||
const state = Constants.makeState({emailError: 'error'}) | ||
const state = {...Constants.makeState(), emailError: 'error'} | ||
expect(_testing.reallySignupOnNoErrors(makeTypedState(state)).next().value).toBeUndefined() | ||
}) | ||
it('bails on inviteCodeError', () => { | ||
const state = Constants.makeState({inviteCodeError: 'error'}) | ||
const state = {...Constants.makeState(), inviteCodeError: 'error'} | ||
expect(_testing.reallySignupOnNoErrors(makeTypedState(state)).next().value).toBeUndefined() | ||
}) | ||
it('bails on nameError', () => { | ||
const state = Constants.makeState({nameError: 'error'}) | ||
const state = {...Constants.makeState(), nameError: 'error'} | ||
expect(_testing.reallySignupOnNoErrors(makeTypedState(state)).next().value).toBeUndefined() | ||
}) | ||
it('bails on usernameError', () => { | ||
const state = Constants.makeState({usernameError: 'error'}) | ||
const state = {...Constants.makeState(), usernameError: 'error'} | ||
expect(_testing.reallySignupOnNoErrors(makeTypedState(state)).next().value).toBeUndefined() | ||
}) | ||
it('bails on signupError', () => { | ||
const state = Constants.makeState({signupError: new RPCError('error', 0)}) | ||
const state = {...Constants.makeState(), signupError: new RPCError('error', 0)} | ||
expect(_testing.reallySignupOnNoErrors(makeTypedState(state)).next().value).toBeUndefined() | ||
}) | ||
|
||
const validSignup = Constants.makeState({ | ||
const validSignup = { | ||
...Constants.makeState(), | ||
devicename: 'a valid devicename', | ||
inviteCode: '1234566', | ||
username: 'testuser', | ||
}) | ||
} | ||
|
||
const signupError = new Error('Missing data for signup') | ||
|
||
it('bails on missing devicename', () => { | ||
expect(() => | ||
_testing.reallySignupOnNoErrors(makeTypedState(validSignup.set('devicename', ''))).next() | ||
_testing.reallySignupOnNoErrors(makeTypedState({...validSignup, devicename: ''})).next() | ||
).toThrow(signupError) | ||
}) | ||
it('bails on missing inviteCode', () => { | ||
expect(() => | ||
_testing.reallySignupOnNoErrors(makeTypedState(validSignup.set('inviteCode', ''))).next() | ||
_testing.reallySignupOnNoErrors(makeTypedState({...validSignup, inviteCode: ''})).next() | ||
).toThrow(signupError) | ||
}) | ||
it('bails on missing username', () => { | ||
expect(() => | ||
_testing.reallySignupOnNoErrors(makeTypedState(validSignup.set('username', ''))).next() | ||
_testing.reallySignupOnNoErrors(makeTypedState({...validSignup, username: ''})).next() | ||
).toThrow(signupError) | ||
}) | ||
it('updates error', () => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.