committed by
GitHub
parent
186484defa
commit
78693f4fc6
@@ -23,15 +23,21 @@ const reducer = (state = defaultState, action) => {
|
||||
...state,
|
||||
thirdPartyAuthApiStatus: PENDING_STATE,
|
||||
};
|
||||
case THIRD_PARTY_AUTH_CONTEXT.SUCCESS:
|
||||
case THIRD_PARTY_AUTH_CONTEXT.SUCCESS: {
|
||||
const extendedProfile = action.payload.optionalFields.extended_profile;
|
||||
const extendedProfileArray = extendedProfile && JSON.parse(extendedProfile.replaceAll('\'', '"'));
|
||||
return {
|
||||
...state,
|
||||
extendedProfile: action.payload.fieldDescriptions.extended_profile,
|
||||
extendedProfile: extendedProfileArray,
|
||||
fieldDescriptions: action.payload.fieldDescriptions.fields,
|
||||
optionalFields: action.payload.optionalFields,
|
||||
optionalFields: {
|
||||
...action.payload.optionalFields,
|
||||
extended_profile: extendedProfileArray,
|
||||
},
|
||||
thirdPartyAuthContext: action.payload.thirdPartyAuthContext,
|
||||
thirdPartyAuthApiStatus: COMPLETE_STATE,
|
||||
};
|
||||
}
|
||||
case THIRD_PARTY_AUTH_CONTEXT.FAILURE:
|
||||
return {
|
||||
...state,
|
||||
|
||||
49
src/common-components/data/tests/reducers.test.js
Normal file
49
src/common-components/data/tests/reducers.test.js
Normal file
@@ -0,0 +1,49 @@
|
||||
import { THIRD_PARTY_AUTH_CONTEXT } from '../actions';
|
||||
import reducer from '../reducers';
|
||||
|
||||
describe('common components reducer', () => {
|
||||
it('should convert extended profile from string to array', () => {
|
||||
const state = {
|
||||
extendedProfile: [],
|
||||
fieldDescriptions: {},
|
||||
optionalFields: {},
|
||||
thirdPartyAuthApiStatus: null,
|
||||
thirdPartyAuthContext: {
|
||||
currentProvider: null,
|
||||
finishAuthUrl: null,
|
||||
countryCode: null,
|
||||
providers: [],
|
||||
secondaryProviders: [],
|
||||
pipelineUserDetails: null,
|
||||
},
|
||||
};
|
||||
const fieldDescriptions = {
|
||||
fields: [],
|
||||
extended_profile: "['state', 'profession']",
|
||||
};
|
||||
const optionalFields = {
|
||||
fields: [],
|
||||
extended_profile: "['state', 'profession']",
|
||||
};
|
||||
const thirdPartyAuthContext = { ...state.thirdPartyAuthContext };
|
||||
const action = {
|
||||
type: THIRD_PARTY_AUTH_CONTEXT.SUCCESS,
|
||||
payload: { fieldDescriptions, optionalFields, thirdPartyAuthContext },
|
||||
};
|
||||
|
||||
expect(
|
||||
reducer(state, action),
|
||||
).toEqual(
|
||||
{
|
||||
...state,
|
||||
extendedProfile: ['state', 'profession'],
|
||||
fieldDescriptions: [],
|
||||
optionalFields: {
|
||||
fields: [],
|
||||
extended_profile: ['state', 'profession'],
|
||||
},
|
||||
thirdPartyAuthApiStatus: 'complete',
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user