Commit 83a67aaa authored by Mark Florian's avatar Mark Florian

Merge branch '208470_03-replicable-store-and-state' into 'master'

Geo Replication - Rename Store/State

See merge request gitlab-org/gitlab!27237
parents d2137e2c 34003aa1
...@@ -28,16 +28,16 @@ export default { ...@@ -28,16 +28,16 @@ export default {
}, },
}, },
computed: { computed: {
...mapState(['isLoading', 'totalDesigns']), ...mapState(['isLoading', 'totalReplicableItems']),
hasDesigns() { hasReplicableItems() {
return this.totalDesigns > 0; return this.totalReplicableItems > 0;
}, },
}, },
created() { created() {
this.fetchDesigns(); this.fetchReplicableItems();
}, },
methods: { methods: {
...mapActions(['fetchDesigns']), ...mapActions(['fetchReplicableItems']),
}, },
}; };
</script> </script>
...@@ -47,7 +47,7 @@ export default { ...@@ -47,7 +47,7 @@ export default {
<geo-designs-filter-bar /> <geo-designs-filter-bar />
<gl-loading-icon v-if="isLoading" size="xl" /> <gl-loading-icon v-if="isLoading" size="xl" />
<template v-else> <template v-else>
<geo-designs v-if="hasDesigns" /> <geo-designs v-if="hasReplicableItems" />
<geo-designs-empty-state <geo-designs-empty-state
v-else v-else
:issues-svg-path="issuesSvgPath" :issues-svg-path="issuesSvgPath"
......
...@@ -66,7 +66,7 @@ export default { ...@@ -66,7 +66,7 @@ export default {
}; };
}, },
methods: { methods: {
...mapActions(['initiateDesignSync']), ...mapActions(['initiateReplicableSync']),
}, },
actionTypes: ACTION_TYPES, actionTypes: ACTION_TYPES,
}; };
...@@ -78,7 +78,7 @@ export default { ...@@ -78,7 +78,7 @@ export default {
<gl-link class="font-weight-bold" :href="`/${name}`" target="_blank">{{ name }}</gl-link> <gl-link class="font-weight-bold" :href="`/${name}`" target="_blank">{{ name }}</gl-link>
<div class="ml-auto"> <div class="ml-auto">
<gl-button <gl-button
@click="initiateDesignSync({ projectId, name, action: $options.actionTypes.RESYNC })" @click="initiateReplicableSync({ projectId, name, action: $options.actionTypes.RESYNC })"
>{{ __('Resync') }}</gl-button >{{ __('Resync') }}</gl-button
> >
</div> </div>
......
...@@ -10,22 +10,22 @@ export default { ...@@ -10,22 +10,22 @@ export default {
GeoDesign, GeoDesign,
}, },
computed: { computed: {
...mapState(['designs', 'currentPage', 'pageSize', 'totalDesigns']), ...mapState(['replicableItems', 'currentPage', 'pageSize', 'totalReplicableItems']),
page: { page: {
get() { get() {
return this.currentPage; return this.currentPage;
}, },
set(newVal) { set(newVal) {
this.setPage(newVal); this.setPage(newVal);
this.fetchDesigns(); this.fetchReplicableItems();
}, },
}, },
hasDesigns() { hasReplicableItems() {
return this.totalDesigns > 0; return this.totalReplicableItems > 0;
}, },
}, },
methods: { methods: {
...mapActions(['setPage', 'fetchDesigns']), ...mapActions(['setPage', 'fetchReplicableItems']),
}, },
}; };
</script> </script>
...@@ -33,20 +33,20 @@ export default { ...@@ -33,20 +33,20 @@ export default {
<template> <template>
<section> <section>
<geo-design <geo-design
v-for="design in designs" v-for="item in replicableItems"
:key="design.id" :key="item.id"
:name="design.name" :name="item.name"
:project-id="design.projectId" :project-id="item.projectId"
:sync-status="design.state" :sync-status="item.state"
:last-synced="design.lastSyncedAt" :last-synced="item.lastSyncedAt"
:last-verified="design.lastVerifiedAt" :last-verified="item.lastVerifiedAt"
:last-checked="design.lastCheckedAt" :last-checked="item.lastCheckedAt"
/> />
<gl-pagination <gl-pagination
v-if="hasDesigns" v-if="hasReplicableItems"
v-model="page" v-model="page"
:per-page="pageSize" :per-page="pageSize"
:total-items="totalDesigns" :total-items="totalReplicableItems"
align="center" align="center"
/> />
</section> </section>
......
...@@ -24,7 +24,7 @@ export default { ...@@ -24,7 +24,7 @@ export default {
}, },
set: debounce(function debounceSearch(newVal) { set: debounce(function debounceSearch(newVal) {
this.setSearch(newVal); this.setSearch(newVal);
this.fetchDesigns(); this.fetchReplicableItems();
}, DEFAULT_SEARCH_DELAY), }, DEFAULT_SEARCH_DELAY),
}, },
resyncText() { resyncText() {
...@@ -32,10 +32,10 @@ export default { ...@@ -32,10 +32,10 @@ export default {
}, },
}, },
methods: { methods: {
...mapActions(['setFilter', 'setSearch', 'fetchDesigns', 'initiateAllDesignSyncs']), ...mapActions(['setFilter', 'setSearch', 'fetchReplicableItems', 'initiateAllReplicableSyncs']),
filterChange(filterIndex) { filterChange(filterIndex) {
this.setFilter(filterIndex); this.setFilter(filterIndex);
this.fetchDesigns(); this.fetchReplicableItems();
}, },
}, },
actionTypes: ACTION_TYPES, actionTypes: ACTION_TYPES,
...@@ -61,7 +61,7 @@ export default { ...@@ -61,7 +61,7 @@ export default {
<icon name="chevron-down" /> <icon name="chevron-down" />
</span> </span>
</template> </template>
<gl-dropdown-item @click="initiateAllDesignSyncs($options.actionTypes.RESYNC)"> <gl-dropdown-item @click="initiateAllReplicableSyncs($options.actionTypes.RESYNC)">
{{ resyncText }} {{ resyncText }}
</gl-dropdown-item> </gl-dropdown-item>
</gl-dropdown> </gl-dropdown>
......
...@@ -23,7 +23,7 @@ export const receiveReplicableItemsError = ({ state, commit }) => { ...@@ -23,7 +23,7 @@ export const receiveReplicableItemsError = ({ state, commit }) => {
commit(types.RECEIVE_REPLICABLE_ITEMS_ERROR); commit(types.RECEIVE_REPLICABLE_ITEMS_ERROR);
}; };
export const fetchDesigns = ({ state, dispatch }) => { export const fetchReplicableItems = ({ state, dispatch }) => {
dispatch('requestReplicableItems'); dispatch('requestReplicableItems');
const statusFilterName = state.filterOptions[state.currentFilterIndex] const statusFilterName = state.filterOptions[state.currentFilterIndex]
...@@ -66,7 +66,7 @@ export const receiveInitiateAllReplicableSyncsSuccess = ( ...@@ -66,7 +66,7 @@ export const receiveInitiateAllReplicableSyncsSuccess = (
}), }),
); );
commit(types.RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_SUCCESS); commit(types.RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_SUCCESS);
dispatch('fetchDesigns'); dispatch('fetchReplicableItems');
}; };
export const receiveInitiateAllReplicableSyncsError = ({ state, commit }) => { export const receiveInitiateAllReplicableSyncsError = ({ state, commit }) => {
createFlash( createFlash(
...@@ -77,7 +77,7 @@ export const receiveInitiateAllReplicableSyncsError = ({ state, commit }) => { ...@@ -77,7 +77,7 @@ export const receiveInitiateAllReplicableSyncsError = ({ state, commit }) => {
commit(types.RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_ERROR); commit(types.RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_ERROR);
}; };
export const initiateAllDesignSyncs = ({ state, dispatch }, action) => { export const initiateAllReplicableSyncs = ({ state, dispatch }, action) => {
dispatch('requestInitiateAllReplicableSyncs'); dispatch('requestInitiateAllReplicableSyncs');
Api.initiateAllGeoReplicableSyncs(state.replicableType, action) Api.initiateAllGeoReplicableSyncs(state.replicableType, action)
...@@ -93,14 +93,14 @@ export const requestInitiateReplicableSync = ({ commit }) => ...@@ -93,14 +93,14 @@ export const requestInitiateReplicableSync = ({ commit }) =>
export const receiveInitiateReplicableSyncSuccess = ({ commit, dispatch }, { name, action }) => { export const receiveInitiateReplicableSyncSuccess = ({ commit, dispatch }, { name, action }) => {
toast(sprintf(__('%{name} is scheduled for %{action}'), { name, action })); toast(sprintf(__('%{name} is scheduled for %{action}'), { name, action }));
commit(types.RECEIVE_INITIATE_REPLICABLE_SYNC_SUCCESS); commit(types.RECEIVE_INITIATE_REPLICABLE_SYNC_SUCCESS);
dispatch('fetchDesigns'); dispatch('fetchReplicableItems');
}; };
export const receiveInitiateReplicableSyncError = ({ commit }, { name }) => { export const receiveInitiateReplicableSyncError = ({ commit }, { name }) => {
createFlash(sprintf(__('There was an error syncing project %{name}'), { name })); createFlash(sprintf(__('There was an error syncing project %{name}'), { name }));
commit(types.RECEIVE_INITIATE_REPLICABLE_SYNC_ERROR); commit(types.RECEIVE_INITIATE_REPLICABLE_SYNC_ERROR);
}; };
export const initiateDesignSync = ({ state, dispatch }, { projectId, name, action }) => { export const initiateReplicableSync = ({ state, dispatch }, { projectId, name, action }) => {
dispatch('requestInitiateReplicableSync'); dispatch('requestInitiateReplicableSync');
Api.initiateGeoReplicableSync(state.replicableType, { projectId, action }) Api.initiateGeoReplicableSync(state.replicableType, { projectId, action })
......
...@@ -17,15 +17,15 @@ export default { ...@@ -17,15 +17,15 @@ export default {
}, },
[types.RECEIVE_REPLICABLE_ITEMS_SUCCESS](state, { data, perPage, total }) { [types.RECEIVE_REPLICABLE_ITEMS_SUCCESS](state, { data, perPage, total }) {
state.isLoading = false; state.isLoading = false;
state.designs = data; state.replicableItems = data;
state.pageSize = perPage; state.pageSize = perPage;
state.totalDesigns = total; state.totalReplicableItems = total;
}, },
[types.RECEIVE_REPLICABLE_ITEMS_ERROR](state) { [types.RECEIVE_REPLICABLE_ITEMS_ERROR](state) {
state.isLoading = false; state.isLoading = false;
state.designs = []; state.replicableItems = [];
state.pageSize = 0; state.pageSize = 0;
state.totalDesigns = 0; state.totalReplicableItems = 0;
}, },
[types.REQUEST_INITIATE_ALL_REPLICABLE_SYNCS](state) { [types.REQUEST_INITIATE_ALL_REPLICABLE_SYNCS](state) {
state.isLoading = true; state.isLoading = true;
......
...@@ -4,8 +4,8 @@ const createState = replicableType => ({ ...@@ -4,8 +4,8 @@ const createState = replicableType => ({
replicableType, replicableType,
isLoading: false, isLoading: false,
designs: [], replicableItems: [],
totalDesigns: 0, totalReplicableItems: 0,
pageSize: 0, pageSize: 0,
currentPage: 1, currentPage: 1,
......
...@@ -26,7 +26,7 @@ describe('GeoDesignsApp', () => { ...@@ -26,7 +26,7 @@ describe('GeoDesignsApp', () => {
}; };
const actionSpies = { const actionSpies = {
fetchDesigns: jest.fn(), fetchReplicableItems: jest.fn(),
setEndpoint: jest.fn(), setEndpoint: jest.fn(),
}; };
...@@ -87,10 +87,10 @@ describe('GeoDesignsApp', () => { ...@@ -87,10 +87,10 @@ describe('GeoDesignsApp', () => {
wrapper.vm.$store.state.isLoading = false; wrapper.vm.$store.state.isLoading = false;
}); });
describe('with designs', () => { describe('with replicableItems', () => {
beforeEach(() => { beforeEach(() => {
wrapper.vm.$store.state.designs = MOCK_BASIC_FETCH_DATA_MAP.data; wrapper.vm.$store.state.replicableItems = MOCK_BASIC_FETCH_DATA_MAP.data;
wrapper.vm.$store.state.totalDesigns = MOCK_BASIC_FETCH_DATA_MAP.total; wrapper.vm.$store.state.totalReplicableItems = MOCK_BASIC_FETCH_DATA_MAP.total;
}); });
it('shows designs', () => { it('shows designs', () => {
...@@ -106,10 +106,10 @@ describe('GeoDesignsApp', () => { ...@@ -106,10 +106,10 @@ describe('GeoDesignsApp', () => {
}); });
}); });
describe('with no designs', () => { describe('with no replicableItems', () => {
beforeEach(() => { beforeEach(() => {
wrapper.vm.$store.state.designs = []; wrapper.vm.$store.state.replicableItems = [];
wrapper.vm.$store.state.totalDesigns = 0; wrapper.vm.$store.state.totalReplicableItems = 0;
}); });
it('hides designs', () => { it('hides designs', () => {
...@@ -132,8 +132,8 @@ describe('GeoDesignsApp', () => { ...@@ -132,8 +132,8 @@ describe('GeoDesignsApp', () => {
createComponent(); createComponent();
}); });
it('calls fetchDesigns', () => { it('calls fetchReplicableItems', () => {
expect(actionSpies.fetchDesigns).toHaveBeenCalled(); expect(actionSpies.fetchReplicableItems).toHaveBeenCalled();
}); });
}); });
}); });
...@@ -14,7 +14,7 @@ describe('GeoDesignsApp', () => { ...@@ -14,7 +14,7 @@ describe('GeoDesignsApp', () => {
const mockDesign = MOCK_BASIC_FETCH_DATA_MAP.data[0]; const mockDesign = MOCK_BASIC_FETCH_DATA_MAP.data[0];
const actionSpies = { const actionSpies = {
initiateDesignSync: jest.fn(), initiateReplicableSync: jest.fn(),
}; };
const propsData = { const propsData = {
...@@ -75,7 +75,7 @@ describe('GeoDesignsApp', () => { ...@@ -75,7 +75,7 @@ describe('GeoDesignsApp', () => {
it('calls initiateDesignSyncs when clicked', () => { it('calls initiateDesignSyncs when clicked', () => {
findGlButton().trigger('click'); findGlButton().trigger('click');
expect(actionSpies.initiateDesignSync).toHaveBeenCalledWith({ expect(actionSpies.initiateReplicableSync).toHaveBeenCalledWith({
projectId: propsData.projectId, projectId: propsData.projectId,
name: propsData.name, name: propsData.name,
action: ACTION_TYPES.RESYNC, action: ACTION_TYPES.RESYNC,
......
...@@ -14,8 +14,8 @@ describe('GeoDesignsFilterBar', () => { ...@@ -14,8 +14,8 @@ describe('GeoDesignsFilterBar', () => {
const actionSpies = { const actionSpies = {
setSearch: jest.fn(), setSearch: jest.fn(),
setFilter: jest.fn(), setFilter: jest.fn(),
fetchDesigns: jest.fn(), fetchReplicableItems: jest.fn(),
initiateAllDesignSyncs: jest.fn(), initiateAllReplicableSyncs: jest.fn(),
}; };
const createComponent = () => { const createComponent = () => {
...@@ -71,10 +71,10 @@ describe('GeoDesignsFilterBar', () => { ...@@ -71,10 +71,10 @@ describe('GeoDesignsFilterBar', () => {
expect(findGlDropdownItem().exists()).toBe(true); expect(findGlDropdownItem().exists()).toBe(true);
}); });
it('calls initiateAllDesignSyncs when clicked', () => { it('calls initiateAllReplicableSyncs when clicked', () => {
const innerButton = findGlDropdownItem().find('button'); const innerButton = findGlDropdownItem().find('button');
innerButton.trigger('click'); innerButton.trigger('click');
expect(actionSpies.initiateAllDesignSyncs).toHaveBeenCalled(); expect(actionSpies.initiateAllReplicableSyncs).toHaveBeenCalled();
}); });
}); });
}); });
...@@ -82,7 +82,7 @@ describe('GeoDesignsFilterBar', () => { ...@@ -82,7 +82,7 @@ describe('GeoDesignsFilterBar', () => {
describe('when search changes', () => { describe('when search changes', () => {
beforeEach(() => { beforeEach(() => {
createComponent(); createComponent();
actionSpies.fetchDesigns.mockClear(); // Will get called on init actionSpies.fetchReplicableItems.mockClear(); // Will get called on init
wrapper.vm.search = 'test search'; wrapper.vm.search = 'test search';
}); });
...@@ -93,11 +93,11 @@ describe('GeoDesignsFilterBar', () => { ...@@ -93,11 +93,11 @@ describe('GeoDesignsFilterBar', () => {
expect(actionSpies.setSearch).toHaveBeenCalledWith('test search'); expect(actionSpies.setSearch).toHaveBeenCalledWith('test search');
}); });
it(`should wait ${DEFAULT_SEARCH_DELAY}ms before calling fetchDesigns`, () => { it(`should wait ${DEFAULT_SEARCH_DELAY}ms before calling fetchReplicableItems`, () => {
expect(actionSpies.fetchDesigns).not.toHaveBeenCalled(); expect(actionSpies.fetchReplicableItems).not.toHaveBeenCalled();
jest.runAllTimers(); // Debounce jest.runAllTimers(); // Debounce
expect(actionSpies.fetchDesigns).toHaveBeenCalled(); expect(actionSpies.fetchReplicableItems).toHaveBeenCalled();
}); });
}); });
...@@ -113,8 +113,8 @@ describe('GeoDesignsFilterBar', () => { ...@@ -113,8 +113,8 @@ describe('GeoDesignsFilterBar', () => {
expect(actionSpies.setFilter).toHaveBeenCalledWith(testValue); expect(actionSpies.setFilter).toHaveBeenCalledWith(testValue);
}); });
it('should call fetchDesigns', () => { it('should call fetchReplicableItems', () => {
expect(actionSpies.fetchDesigns).toHaveBeenCalled(); expect(actionSpies.fetchReplicableItems).toHaveBeenCalled();
}); });
}); });
}); });
...@@ -14,7 +14,7 @@ describe('GeoDesigns', () => { ...@@ -14,7 +14,7 @@ describe('GeoDesigns', () => {
const actionSpies = { const actionSpies = {
setPage: jest.fn(), setPage: jest.fn(),
fetchDesigns: jest.fn(), fetchReplicableItems: jest.fn(),
}; };
const createComponent = () => { const createComponent = () => {
...@@ -45,10 +45,10 @@ describe('GeoDesigns', () => { ...@@ -45,10 +45,10 @@ describe('GeoDesigns', () => {
}); });
describe('GlPagination', () => { describe('GlPagination', () => {
describe('when pageSize >= totalDesigns', () => { describe('when pageSize >= totalReplicableItems', () => {
beforeEach(() => { beforeEach(() => {
wrapper.vm.$store.state.pageSize = 2; wrapper.vm.$store.state.pageSize = 2;
wrapper.vm.$store.state.totalDesigns = 1; wrapper.vm.$store.state.totalReplicableItems = 1;
}); });
it('is hidden', () => { it('is hidden', () => {
...@@ -56,10 +56,10 @@ describe('GeoDesigns', () => { ...@@ -56,10 +56,10 @@ describe('GeoDesigns', () => {
}); });
}); });
describe('when pageSize < totalDesigns', () => { describe('when pageSize < totalReplicableItems', () => {
beforeEach(() => { beforeEach(() => {
wrapper.vm.$store.state.pageSize = 1; wrapper.vm.$store.state.pageSize = 1;
wrapper.vm.$store.state.totalDesigns = 2; wrapper.vm.$store.state.totalReplicableItems = 2;
}); });
it('renders', () => { it('renders', () => {
...@@ -70,15 +70,15 @@ describe('GeoDesigns', () => { ...@@ -70,15 +70,15 @@ describe('GeoDesigns', () => {
describe('GeoDesign', () => { describe('GeoDesign', () => {
beforeEach(() => { beforeEach(() => {
wrapper.vm.$store.state.designs = MOCK_BASIC_FETCH_DATA_MAP.data; wrapper.vm.$store.state.replicableItems = MOCK_BASIC_FETCH_DATA_MAP.data;
}); });
it('renders an instance for each design in the store', () => { it('renders an instance for each design in the store', () => {
const designWrappers = findGeoDesign(); const designWrappers = findGeoDesign();
const designs = [...wrapper.vm.$store.state.designs]; const replicableItems = [...wrapper.vm.$store.state.replicableItems];
for (let i = 0; i < designWrappers.length; i += 1) { for (let i = 0; i < designWrappers.length; i += 1) {
expect(designWrappers.at(i).props().projectId).toBe(designs[i].projectId); expect(designWrappers.at(i).props().projectId).toBe(replicableItems[i].projectId);
} }
}); });
}); });
...@@ -94,8 +94,8 @@ describe('GeoDesigns', () => { ...@@ -94,8 +94,8 @@ describe('GeoDesigns', () => {
expect(actionSpies.setPage).toHaveBeenCalledWith(2); expect(actionSpies.setPage).toHaveBeenCalledWith(2);
}); });
it('should call fetchDesigns', () => { it('should call fetchReplicableItems', () => {
expect(actionSpies.fetchDesigns).toHaveBeenCalled(); expect(actionSpies.fetchReplicableItems).toHaveBeenCalled();
}); });
}); });
}); });
...@@ -64,7 +64,7 @@ describe('GeoDesigns Store Actions', () => { ...@@ -64,7 +64,7 @@ describe('GeoDesigns Store Actions', () => {
}); });
}); });
describe('fetchDesigns', () => { describe('fetchReplicableItems', () => {
describe('on success', () => { describe('on success', () => {
beforeEach(() => { beforeEach(() => {
jest.spyOn(Api, 'getGeoReplicableItems').mockResolvedValue(MOCK_BASIC_FETCH_RESPONSE); jest.spyOn(Api, 'getGeoReplicableItems').mockResolvedValue(MOCK_BASIC_FETCH_RESPONSE);
...@@ -79,7 +79,7 @@ describe('GeoDesigns Store Actions', () => { ...@@ -79,7 +79,7 @@ describe('GeoDesigns Store Actions', () => {
it('should call getGeoReplicableItems with default queryParams', () => { it('should call getGeoReplicableItems with default queryParams', () => {
testAction( testAction(
actions.fetchDesigns, actions.fetchReplicableItems,
{}, {},
state, state,
[], [],
...@@ -106,7 +106,7 @@ describe('GeoDesigns Store Actions', () => { ...@@ -106,7 +106,7 @@ describe('GeoDesigns Store Actions', () => {
it('should call getGeoReplicableItems with default queryParams', () => { it('should call getGeoReplicableItems with default queryParams', () => {
testAction( testAction(
actions.fetchDesigns, actions.fetchReplicableItems,
{}, {},
state, state,
[], [],
...@@ -133,7 +133,7 @@ describe('GeoDesigns Store Actions', () => { ...@@ -133,7 +133,7 @@ describe('GeoDesigns Store Actions', () => {
it('should dispatch the request and error actions', done => { it('should dispatch the request and error actions', done => {
testAction( testAction(
actions.fetchDesigns, actions.fetchReplicableItems,
{}, {},
state, state,
[], [],
...@@ -158,13 +158,13 @@ describe('GeoDesigns Store Actions', () => { ...@@ -158,13 +158,13 @@ describe('GeoDesigns Store Actions', () => {
}); });
describe('receiveInitiateAllReplicableSyncsSuccess', () => { describe('receiveInitiateAllReplicableSyncsSuccess', () => {
it('should commit mutation RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_SUCCESS and call fetchDesigns and toast', () => { it('should commit mutation RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_SUCCESS and call fetchReplicableItems and toast', () => {
testAction( testAction(
actions.receiveInitiateAllReplicableSyncsSuccess, actions.receiveInitiateAllReplicableSyncsSuccess,
{ action: ACTION_TYPES.RESYNC }, { action: ACTION_TYPES.RESYNC },
state, state,
[{ type: types.RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_SUCCESS }], [{ type: types.RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_SUCCESS }],
[{ type: 'fetchDesigns' }], [{ type: 'fetchReplicableItems' }],
() => { () => {
expect(toast).toHaveBeenCalledTimes(1); expect(toast).toHaveBeenCalledTimes(1);
toast.mockClear(); toast.mockClear();
...@@ -188,7 +188,7 @@ describe('GeoDesigns Store Actions', () => { ...@@ -188,7 +188,7 @@ describe('GeoDesigns Store Actions', () => {
}); });
}); });
describe('initiateAllDesignSyncs', () => { describe('initiateAllReplicableSyncs', () => {
let action; let action;
describe('on success', () => { describe('on success', () => {
...@@ -201,7 +201,7 @@ describe('GeoDesigns Store Actions', () => { ...@@ -201,7 +201,7 @@ describe('GeoDesigns Store Actions', () => {
it('should dispatch the request with correct replicable param and success actions', () => { it('should dispatch the request with correct replicable param and success actions', () => {
testAction( testAction(
actions.initiateAllDesignSyncs, actions.initiateAllReplicableSyncs,
action, action,
state, state,
[], [],
...@@ -227,7 +227,7 @@ describe('GeoDesigns Store Actions', () => { ...@@ -227,7 +227,7 @@ describe('GeoDesigns Store Actions', () => {
it('should dispatch the request and error actions', done => { it('should dispatch the request and error actions', done => {
testAction( testAction(
actions.initiateAllDesignSyncs, actions.initiateAllReplicableSyncs,
action, action,
state, state,
[], [],
...@@ -255,13 +255,13 @@ describe('GeoDesigns Store Actions', () => { ...@@ -255,13 +255,13 @@ describe('GeoDesigns Store Actions', () => {
}); });
describe('receiveInitiateReplicableSyncSuccess', () => { describe('receiveInitiateReplicableSyncSuccess', () => {
it('should commit mutation RECEIVE_INITIATE_REPLICABLE_SYNC_SUCCESS and call fetchDesigns and toast', () => { it('should commit mutation RECEIVE_INITIATE_REPLICABLE_SYNC_SUCCESS and call fetchReplicableItems and toast', () => {
testAction( testAction(
actions.receiveInitiateReplicableSyncSuccess, actions.receiveInitiateReplicableSyncSuccess,
{ action: ACTION_TYPES.RESYNC, projectName: 'test' }, { action: ACTION_TYPES.RESYNC, projectName: 'test' },
state, state,
[{ type: types.RECEIVE_INITIATE_REPLICABLE_SYNC_SUCCESS }], [{ type: types.RECEIVE_INITIATE_REPLICABLE_SYNC_SUCCESS }],
[{ type: 'fetchDesigns' }], [{ type: 'fetchReplicableItems' }],
() => { () => {
expect(toast).toHaveBeenCalledTimes(1); expect(toast).toHaveBeenCalledTimes(1);
toast.mockClear(); toast.mockClear();
...@@ -285,7 +285,7 @@ describe('GeoDesigns Store Actions', () => { ...@@ -285,7 +285,7 @@ describe('GeoDesigns Store Actions', () => {
}); });
}); });
describe('initiateDesignSync', () => { describe('initiateReplicableSync', () => {
let action; let action;
let projectId; let projectId;
let name; let name;
...@@ -300,7 +300,7 @@ describe('GeoDesigns Store Actions', () => { ...@@ -300,7 +300,7 @@ describe('GeoDesigns Store Actions', () => {
it('should dispatch the request with correct replicable param and success actions', () => { it('should dispatch the request with correct replicable param and success actions', () => {
testAction( testAction(
actions.initiateDesignSync, actions.initiateReplicableSync,
{ projectId, name, action }, { projectId, name, action },
state, state,
[], [],
...@@ -328,7 +328,7 @@ describe('GeoDesigns Store Actions', () => { ...@@ -328,7 +328,7 @@ describe('GeoDesigns Store Actions', () => {
it('should dispatch the request and error actions', done => { it('should dispatch the request and error actions', done => {
testAction( testAction(
actions.initiateDesignSync, actions.initiateReplicableSync,
{ projectId, name, action }, { projectId, name, action },
state, state,
[], [],
......
...@@ -78,13 +78,13 @@ describe('GeoReplicable Store Mutations', () => { ...@@ -78,13 +78,13 @@ describe('GeoReplicable Store Mutations', () => {
it('sets designs array with data', () => { it('sets designs array with data', () => {
mutations[types.RECEIVE_REPLICABLE_ITEMS_SUCCESS](state, mockData); mutations[types.RECEIVE_REPLICABLE_ITEMS_SUCCESS](state, mockData);
expect(state.designs).toBe(mockData.data); expect(state.replicableItems).toBe(mockData.data);
}); });
it('sets pageSize and totalDesigns', () => { it('sets pageSize and totalDesigns', () => {
mutations[types.RECEIVE_REPLICABLE_ITEMS_SUCCESS](state, mockData); mutations[types.RECEIVE_REPLICABLE_ITEMS_SUCCESS](state, mockData);
expect(state.pageSize).toEqual(mockData.perPage); expect(state.pageSize).toEqual(mockData.perPage);
expect(state.totalDesigns).toEqual(mockData.total); expect(state.totalReplicableItems).toEqual(mockData.total);
}); });
}); });
...@@ -103,19 +103,19 @@ describe('GeoReplicable Store Mutations', () => { ...@@ -103,19 +103,19 @@ describe('GeoReplicable Store Mutations', () => {
}); });
it('resets designs array', () => { it('resets designs array', () => {
state.designs = mockData.data; state.replicableItems = mockData.data;
mutations[types.RECEIVE_REPLICABLE_ITEMS_ERROR](state); mutations[types.RECEIVE_REPLICABLE_ITEMS_ERROR](state);
expect(state.designs).toEqual([]); expect(state.replicableItems).toEqual([]);
}); });
it('resets pagination data', () => { it('resets pagination data', () => {
state.pageSize = mockData.perPage; state.pageSize = mockData.perPage;
state.totalDesigns = mockData.total; state.totalReplicableItems = mockData.total;
mutations[types.RECEIVE_REPLICABLE_ITEMS_ERROR](state); mutations[types.RECEIVE_REPLICABLE_ITEMS_ERROR](state);
expect(state.pageSize).toEqual(0); expect(state.pageSize).toEqual(0);
expect(state.totalDesigns).toEqual(0); expect(state.totalReplicableItems).toEqual(0);
}); });
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment