-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Task: support multiple collections (#2549)
- Loading branch information
Showing
20 changed files
with
446 additions
and
199 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
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
87 changes: 87 additions & 0 deletions
87
src/app/services/actions/collections-action-creators.spec.ts
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 |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import configureMockStore from 'redux-mock-store'; | ||
import thunk from 'redux-thunk'; | ||
|
||
import { | ||
RESOURCEPATHS_ADD_SUCCESS, RESOURCEPATHS_DELETE_SUCCESS | ||
} from '../redux-constants'; | ||
import { addResourcePaths, removeResourcePaths } from './collections-action-creators'; | ||
|
||
const middlewares = [thunk]; | ||
const mockStore = configureMockStore(middlewares); | ||
|
||
const paths = [ | ||
{ | ||
key: '5-{serviceHealth-id}-issues', | ||
url: '/admin/serviceAnnouncement/healthOverviews/{serviceHealth-id}/issues', | ||
name: 'issues (1)', | ||
labels: [ | ||
{ name: 'v1.0', methods: ['Get', 'Post'] }, | ||
{ name: 'beta', methods: ['Get', 'Post'] } | ||
], | ||
isExpanded: true, | ||
parent: '{serviceHealth-id}', | ||
level: 5, | ||
paths: ['/', 'admin', 'serviceAnnouncement', 'healthOverviews', '{serviceHealth-id}'], | ||
type: 'path', | ||
links: [] | ||
}, { | ||
key: '6-issues-{serviceHealthIssue-id}', | ||
url: '/admin/serviceAnnouncement/healthOverviews/{serviceHealth-id}/issues/{serviceHealthIssue-id}', | ||
name: '{serviceHealthIssue-id} (1)', | ||
labels: [ | ||
{ name: 'v1.0', methods: ['Get', 'Patch', 'Delete'] }, | ||
{ name: 'beta', methods: ['Get', 'Patch', 'Delete'] } | ||
], | ||
isExpanded: true, | ||
parent: 'issues', | ||
level: 6, | ||
paths: ['/', 'admin', 'serviceAnnouncement', 'healthOverviews', '{serviceHealth-id}', 'issues'], | ||
type: 'path', | ||
links: [] | ||
} | ||
]; | ||
|
||
describe('Collections actions', () => { | ||
beforeEach(() => { | ||
fetchMock.resetMocks(); | ||
}); | ||
|
||
it('should dispatch RESOURCEPATHS_ADD_SUCCESS when addResourcePaths() is called with valid paths', () => { | ||
|
||
const expectedActions = [ | ||
{ | ||
type: RESOURCEPATHS_ADD_SUCCESS, | ||
response: paths | ||
} | ||
]; | ||
|
||
const store_ = mockStore({ | ||
resources: { | ||
paths: [] | ||
} | ||
}); | ||
|
||
store_.dispatch(addResourcePaths(paths)); | ||
expect(store_.getActions()).toEqual(expectedActions); | ||
}); | ||
|
||
it('should dispatch RESOURCEPATHS_DELETE_SUCCESS when removeResourcePaths() is dispatched', () => { | ||
|
||
const expectedActions = [ | ||
{ | ||
type: RESOURCEPATHS_DELETE_SUCCESS, | ||
response: paths | ||
} | ||
]; | ||
|
||
const store_ = mockStore({ | ||
resources: { | ||
paths | ||
} | ||
}); | ||
|
||
store_.dispatch(removeResourcePaths(paths)); | ||
expect(store_.getActions()).toEqual(expectedActions); | ||
}) | ||
|
||
}); |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { AppAction } from '../../../types/action'; | ||
import { | ||
COLLECTION_CREATE_SUCCESS, | ||
RESOURCEPATHS_ADD_SUCCESS, RESOURCEPATHS_DELETE_SUCCESS | ||
} from '../redux-constants'; | ||
|
||
export function addResourcePaths(response: object): AppAction { | ||
return { | ||
type: RESOURCEPATHS_ADD_SUCCESS, | ||
response | ||
}; | ||
} | ||
|
||
export function createCollection(response: object): AppAction { | ||
return { | ||
type: COLLECTION_CREATE_SUCCESS, | ||
response | ||
}; | ||
} | ||
|
||
export function removeResourcePaths(response: object): AppAction { | ||
return { | ||
type: RESOURCEPATHS_DELETE_SUCCESS, | ||
response | ||
}; | ||
} |
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
Oops, something went wrong.