-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/v1.15.0' into fix/masthead-l1-mobile-landscape
- Loading branch information
Showing
9 changed files
with
79 additions
and
64 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 |
---|---|---|
|
@@ -10,10 +10,10 @@ | |
import configureMockStore from 'redux-mock-store'; | ||
import { AnyAction } from 'redux'; | ||
import thunk, { ThunkDispatch } from 'redux-thunk'; | ||
// import ProfileAPI from '@carbon/ibmdotcom-services/es/services/Profile/Profile.js'; | ||
import { PROFILE_API_ACTION, ProfileAPIState } from '../../types/profileAPI'; | ||
// import convertValue from '../../../tests/utils/convert-value'; | ||
import { setUserStatus } from '../profileAPI'; | ||
import ProfileAPI from '@carbon/ibmdotcom-services/es/services/Profile/Profile.js'; | ||
import { UNAUTHENTICATED_STATUS, PROFILE_API_ACTION, ProfileAPIState } from '../../types/profileAPI'; | ||
import convertValue from '../../../tests/utils/convert-value'; | ||
import { loadUserStatus, setUserStatus } from '../profileAPI'; | ||
|
||
jest.mock('@carbon/ibmdotcom-services/es/services/Profile/Profile'); | ||
|
||
|
@@ -29,38 +29,46 @@ describe('Redux actions for `ProfileAPI`', () => { | |
expect(store.getActions()).toEqual([ | ||
{ | ||
type: PROFILE_API_ACTION.SET_USER_STATUS, | ||
status: { user: '[email protected]' }, | ||
request: { user: '[email protected]' }, | ||
}, | ||
]); | ||
}); | ||
|
||
// it('dispatches the action to get user authentication status', async () => { | ||
// ProfileAPI.getUserStatus.mockResolvedValue({ user: 'Unauthenticated' }); | ||
// const store = mockStore(); | ||
// await store.dispatch(ProfileAPI.getUserStatus()); | ||
// expect(convertValue(store.getActions())).toEqual([ | ||
// { | ||
// type: PROFILE_API_ACTION.SET_REQUEST_USER_STATUS_IN_PROGRESS, | ||
// request: 'PROMISE', | ||
// }, | ||
// { | ||
// type: PROFILE_API_ACTION.SET_USER_STATUS, | ||
// status: { user: 'Unauthenticated' }, | ||
// }, | ||
// ]); | ||
// }); | ||
it('dispatches the action to get user authentication status', async () => { | ||
ProfileAPI.getUserStatus.mockResolvedValue({ user: UNAUTHENTICATED_STATUS }); | ||
const store = mockStore(); | ||
await store.dispatch(loadUserStatus()); | ||
expect(convertValue(store.getActions())).toEqual([ | ||
{ | ||
type: PROFILE_API_ACTION.SET_REQUEST_USER_STATUS_IN_PROGRESS, | ||
request: 'PROMISE', | ||
}, | ||
{ | ||
type: PROFILE_API_ACTION.SET_USER_STATUS, | ||
request: { user: UNAUTHENTICATED_STATUS }, | ||
}, | ||
]); | ||
}); | ||
|
||
// it('dispatches the action of error in monitoring user authentication status', () => { | ||
// ProfileAPI.getUserStatus.mockImplementation(callback => { | ||
// callback(new Error('error-getuserstatus')); | ||
// }); | ||
// const store = mockStore(); | ||
// store.dispatch(getUserStatus()); | ||
// expect(convertValue(store.getActions())).toEqual([ | ||
// { | ||
// type: PROFILE_API_ACTION.SET_ERROR_REQUEST_USER_STATUS, | ||
// error: 'error-getuserstatus', | ||
// }, | ||
// ]); | ||
// }); | ||
it('dispatches the action of error in monitoring user authentication status', async () => { | ||
ProfileAPI.getUserStatus.mockRejectedValue(new Error('error-getuserstatus')); | ||
const store = mockStore(); | ||
let caught; | ||
try { | ||
await store.dispatch(loadUserStatus()); | ||
} catch (error) { | ||
caught = error; | ||
} | ||
expect(caught?.message).toBe('error-getuserstatus'); | ||
expect(convertValue(store.getActions())).toEqual([ | ||
{ | ||
type: PROFILE_API_ACTION.SET_REQUEST_USER_STATUS_IN_PROGRESS, | ||
request: 'PROMISE', | ||
}, | ||
{ | ||
type: PROFILE_API_ACTION.SET_ERROR_REQUEST_USER_STATUS, | ||
error: 'error-getuserstatus', | ||
}, | ||
]); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ import reducer from '../profileAPI'; | |
|
||
describe('Redux reducers for `ProfileAPI`', () => { | ||
it('should return the state unmodified for unknown action', () => { | ||
const state = { status: { user: '[email protected]' } }; | ||
const state = { request: { user: '[email protected]' } }; | ||
expect(reducer(state, {} as ProfileAPIActions)).toEqual(state); | ||
}); | ||
|
||
|
@@ -36,11 +36,11 @@ describe('Redux reducers for `ProfileAPI`', () => { | |
convertValue( | ||
reducer({} as ProfileAPIState, { | ||
type: PROFILE_API_ACTION.SET_USER_STATUS, | ||
status: { user: '[email protected]' }, | ||
request: { user: '[email protected]' }, | ||
}) | ||
) | ||
).toEqual({ | ||
status: { user: '[email protected]' }, | ||
request: { user: '[email protected]' }, | ||
}); | ||
}); | ||
}); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,12 +18,13 @@ import DDSLeftNav from '../left-nav'; | |
import '../masthead-container'; | ||
import styles from './masthead.stories.scss'; | ||
import { mastheadLinks as links, l1Data, logoData } from './links'; | ||
import { UNAUTHENTICATED_STATUS } from '../../../internal/vendor/@carbon/ibmdotcom-services-store/types/profileAPI'; | ||
import { authenticatedProfileItems, unauthenticatedProfileItems } from './profile-items'; | ||
import readme from './README.stories.mdx'; | ||
|
||
const userStatuses = { | ||
[`Authenticated`]: '[email protected]', | ||
[`Unauthenticated`]: 'Unauthenticated', | ||
[`Unauthenticated`]: UNAUTHENTICATED_STATUS, | ||
}; | ||
|
||
const StoryContent = () => html` | ||
|
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