Make mocks more consistent

parent 5490a663
...@@ -3,12 +3,12 @@ import PolicyDrawer from 'ee/threat_monitoring/components/policy_drawer/policy_d ...@@ -3,12 +3,12 @@ import PolicyDrawer from 'ee/threat_monitoring/components/policy_drawer/policy_d
import ScanExecutionPolicy from 'ee/threat_monitoring/components/policy_drawer/scan_execution_policy.vue'; import ScanExecutionPolicy from 'ee/threat_monitoring/components/policy_drawer/scan_execution_policy.vue';
import { mountExtended } from 'helpers/vue_test_utils_helper'; import { mountExtended } from 'helpers/vue_test_utils_helper';
import { import {
mockPoliciesResponse, mockNetworkPoliciesResponse,
mockCiliumPolicy, mockCiliumPolicy,
mockScanExecutionPolicy, mockScanExecutionPolicy,
} from '../../mocks/mock_data'; } from '../../mocks/mock_data';
const [mockGenericPolicy] = mockPoliciesResponse; const [mockGenericPolicy] = mockNetworkPoliciesResponse;
describe('PolicyDrawer component', () => { describe('PolicyDrawer component', () => {
let wrapper; let wrapper;
......
...@@ -10,7 +10,7 @@ import createMockApolloProvider from 'helpers/mock_apollo_helper'; ...@@ -10,7 +10,7 @@ import createMockApolloProvider from 'helpers/mock_apollo_helper';
import { stubComponent } from 'helpers/stub_component'; import { stubComponent } from 'helpers/stub_component';
import { mountExtended, shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { mountExtended, shallowMountExtended } from 'helpers/vue_test_utils_helper';
import { networkPolicies, scanExecutionPolicies } from '../mocks/mock_apollo'; import { networkPolicies, scanExecutionPolicies } from '../mocks/mock_apollo';
import { mockPoliciesResponse, mockScanExecutionPolicy } from '../mocks/mock_data'; import { mockNetworkPoliciesResponse, mockScanExecutionPoliciesResponse } from '../mocks/mock_data';
const localVue = createLocalVue(); const localVue = createLocalVue();
localVue.use(VueApollo); localVue.use(VueApollo);
...@@ -23,8 +23,8 @@ const environments = [ ...@@ -23,8 +23,8 @@ const environments = [
}, },
]; ];
const defaultRequestHandlers = { const defaultRequestHandlers = {
networkPolicies: networkPolicies(mockPoliciesResponse), networkPolicies: networkPolicies(mockNetworkPoliciesResponse),
scanExecutionPolicies: scanExecutionPolicies([mockScanExecutionPolicy]), scanExecutionPolicies: scanExecutionPolicies(mockScanExecutionPoliciesResponse),
}; };
const pendingHandler = jest.fn(() => new Promise(() => {})); const pendingHandler = jest.fn(() => new Promise(() => {}));
...@@ -152,7 +152,7 @@ describe('PolicyList component', () => { ...@@ -152,7 +152,7 @@ describe('PolicyList component', () => {
it('passes all policies to the table', () => { it('passes all policies to the table', () => {
expect(cloneDeep(wrapper.findByTestId('table').props('items'))).toEqual([ expect(cloneDeep(wrapper.findByTestId('table').props('items'))).toEqual([
expect.objectContaining({ expect.objectContaining({
name: mockPoliciesResponse[0].name, name: mockNetworkPoliciesResponse[0].name,
}), }),
expect.objectContaining({ expect.objectContaining({
name: 'drop-outbound', name: 'drop-outbound',
...@@ -161,7 +161,7 @@ describe('PolicyList component', () => { ...@@ -161,7 +161,7 @@ describe('PolicyList component', () => {
name: 'allow-inbound-http', name: 'allow-inbound-http',
}), }),
expect.objectContaining({ expect.objectContaining({
name: mockScanExecutionPolicy.name, name: mockScanExecutionPoliciesResponse[0].name,
}), }),
]); ]);
}); });
...@@ -182,7 +182,7 @@ describe('PolicyList component', () => { ...@@ -182,7 +182,7 @@ describe('PolicyList component', () => {
describe('given there is a selected policy', () => { describe('given there is a selected policy', () => {
beforeEach(() => { beforeEach(() => {
mountShallowWrapper(); mountShallowWrapper();
findPoliciesTable().vm.$emit('row-selected', [mockPoliciesResponse[0]]); findPoliciesTable().vm.$emit('row-selected', [mockNetworkPoliciesResponse[0]]);
}); });
it('renders opened editor drawer', () => { it('renders opened editor drawer', () => {
...@@ -195,7 +195,7 @@ describe('PolicyList component', () => { ...@@ -195,7 +195,7 @@ describe('PolicyList component', () => {
describe('given an autodevops policy', () => { describe('given an autodevops policy', () => {
beforeEach(() => { beforeEach(() => {
const autoDevOpsPolicy = { const autoDevOpsPolicy = {
...mockPoliciesResponse[0], ...mockNetworkPoliciesResponse[0],
name: 'auto-devops', name: 'auto-devops',
fromAutoDevops: true, fromAutoDevops: true,
}; };
......
...@@ -15,7 +15,7 @@ export const mockEnvironmentsResponse = { ...@@ -15,7 +15,7 @@ export const mockEnvironmentsResponse = {
stopped_count: 5, stopped_count: 5,
}; };
export const mockPoliciesResponse = [ export const mockNetworkPoliciesResponse = [
{ {
name: 'policy', name: 'policy',
yaml: `--- yaml: `---
...@@ -71,6 +71,8 @@ actions: ...@@ -71,6 +71,8 @@ actions:
enabled: true, enabled: true,
}; };
export const mockScanExecutionPoliciesResponse = [mockScanExecutionPolicy];
export const mockNominalHistory = [ export const mockNominalHistory = [
['2019-12-04T00:00:00.000Z', 56], ['2019-12-04T00:00:00.000Z', 56],
['2019-12-05T00:00:00.000Z', 2647], ['2019-12-05T00:00:00.000Z', 2647],
......
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