Commit fbee16a3 authored by samdbeckham's avatar samdbeckham

Adds changes from @kushalpandya review

- improves tests with beforeEach and stricter value checks
- improves actions to reduce additional desctructuring
- uses vue.$options to improve the report_type_popover i18n
parent bb879b2b
<script>
import { GlPopover } from '@gitlab/ui';
import { s__ } from '~/locale';
import Icon from '~/vue_shared/components/icon.vue';
export default {
......@@ -13,6 +14,7 @@ export default {
required: true,
},
},
linkTitle: s__('Security Reports|Security dashboard documentation'),
};
</script>
......@@ -33,12 +35,10 @@ export default {
v-if="dashboardDocumentation"
target="_blank"
rel="noopener noreferrer"
:title="s__('Security Reports|Security dashboard documentation')"
:title="$options.linkTitle"
:href="dashboardDocumentation"
>
<span class="vertical-align-middle">{{
s__('Security Reports|Security dashboard documentation')
}}</span>
<span class="vertical-align-middle">{{ $options.linkTitle }}</span>
<icon name="external-link" :size="16" class="vertical-align-middle" />
</a>
</gl-popover>
......
......@@ -12,9 +12,8 @@ export const fetchProjects = ({ state, dispatch }) => {
method: 'GET',
url: state.projectsEndpoint,
})
.then(response => {
const { data } = response;
dispatch('receiveProjectsSuccess', { data });
.then(({ data }) => {
dispatch('receiveProjectsSuccess', { projects: data });
})
.catch(() => {
dispatch('receiveProjectsError');
......@@ -25,9 +24,7 @@ export const requestProjects = ({ commit }) => {
commit(types.REQUEST_PROJECTS);
};
export const receiveProjectsSuccess = ({ commit }, { data }) => {
const projects = data;
export const receiveProjectsSuccess = ({ commit }, { projects }) => {
commit(types.RECEIVE_PROJECTS_SUCCESS, { projects });
};
......
......@@ -17,10 +17,14 @@ describe('filters module getters', () => {
getFilterIds,
};
};
let state;
beforeEach(() => {
state = createState();
});
describe('getFilter', () => {
it('should return the type filter information', () => {
const state = createState();
const typeFilter = getters.getFilter(state)('report_type');
expect(typeFilter.name).toEqual('Report type');
......@@ -30,7 +34,6 @@ describe('filters module getters', () => {
describe('getSelectedOptions', () => {
describe('with one selected option', () => {
it('should return "All" as the selected option', () => {
const state = createState();
const selectedOptions = getters.getSelectedOptions(state, mockedGetters(state))(
'report_type',
);
......@@ -42,7 +45,7 @@ describe('filters module getters', () => {
describe('with multiple selected options', () => {
it('should return both "High" and "Critical" ', () => {
const state = {
state = {
filters: [
{
id: 'severity',
......@@ -59,7 +62,6 @@ describe('filters module getters', () => {
describe('getSelectedOptionIds', () => {
it('should return "one" as the selcted dummy ID', () => {
const state = createState();
const dummyFilter = {
id: 'dummy',
options: [{ id: 'one', selected: true }, { id: 'anotherone', selected: false }],
......@@ -74,7 +76,6 @@ describe('filters module getters', () => {
describe('getSelectedOptionNames', () => {
it('should return "All" as the selected option', () => {
const state = createState();
const selectedOptionNames = getters.getSelectedOptionNames(state, mockedGetters(state))(
'severity',
);
......@@ -83,7 +84,7 @@ describe('filters module getters', () => {
});
it('should return the correct message when multiple filters are selected', () => {
const state = {
state = {
filters: [
{
id: 'severity',
......@@ -101,14 +102,12 @@ describe('filters module getters', () => {
describe('activeFilters', () => {
it('should return no severity filters', () => {
const state = createState();
const activeFilters = getters.activeFilters(state, mockedGetters(state));
expect(activeFilters.severity).toHaveLength(0);
});
it('should return multiple dummy filters"', () => {
const state = createState();
const dummyFilter = {
id: 'dummy',
options: [{ id: 'one', selected: true }, { id: 'anotherone', selected: true }],
......
......@@ -41,7 +41,7 @@ describe('projects actions', () => {
{ type: 'requestProjects' },
{
type: 'receiveProjectsSuccess',
payload: { data },
payload: { projects: data },
},
],
done,
......@@ -73,7 +73,7 @@ describe('projects actions', () => {
testAction(
actions.receiveProjectsSuccess,
{ data },
{ projects: data },
state,
[
{
......
......@@ -27,11 +27,11 @@ describe('projects module mutations', () => {
});
it('should set `isLoadingProjects` to `true`', () => {
expect(state.isLoadingProjects).toBeTruthy();
expect(state.isLoadingProjects).toBe(true);
});
it('should set `errorLoadingProjects` to `false`', () => {
expect(state.errorLoadingProjects).toBeFalsy();
expect(state.errorLoadingProjects).toBe(false);
});
});
......@@ -48,7 +48,7 @@ describe('projects module mutations', () => {
});
it('should set `isLoadingProjects` to `false`', () => {
expect(state.isLoadingProjects).toBeFalsy();
expect(state.isLoadingProjects).toBe(false);
});
it('should set `pageInfo`', () => {
......@@ -66,7 +66,7 @@ describe('projects module mutations', () => {
mutations[types.RECEIVE_PROJECTS_ERROR](state);
expect(state.isLoadingProjects).toBeFalsy();
expect(state.isLoadingProjects).toBe(false);
});
});
});
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