Commit e545a26f authored by Phil Hughes's avatar Phil Hughes

Move Geo Nodes specs to Jest

Closes https://gitlab.com/gitlab-org/gitlab/issues/36804
parent b7c712ea
...@@ -209,7 +209,7 @@ export default { ...@@ -209,7 +209,7 @@ export default {
<gl-loading-icon <gl-loading-icon
v-if="isLoading" v-if="isLoading"
:label="s__('GeoNodes|Loading nodes')" :label="s__('GeoNodes|Loading nodes')"
:size="2" size="md"
class="loading-animation prepend-top-20 append-bottom-20" class="loading-animation prepend-top-20 append-bottom-20"
/> />
<geo-node-item <geo-node-item
......
...@@ -5,7 +5,7 @@ import appComponent from 'ee/geo_nodes/components/app.vue'; ...@@ -5,7 +5,7 @@ import appComponent from 'ee/geo_nodes/components/app.vue';
import eventHub from 'ee/geo_nodes/event_hub'; import eventHub from 'ee/geo_nodes/event_hub';
import GeoNodesStore from 'ee/geo_nodes/store/geo_nodes_store'; import GeoNodesStore from 'ee/geo_nodes/store/geo_nodes_store';
import GeoNodesService from 'ee/geo_nodes/service/geo_nodes_service'; import GeoNodesService from 'ee/geo_nodes/service/geo_nodes_service';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
import { NODE_ACTIONS } from 'ee/geo_nodes/constants'; import { NODE_ACTIONS } from 'ee/geo_nodes/constants';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { import {
...@@ -16,6 +16,9 @@ import { ...@@ -16,6 +16,9 @@ import {
rawMockNodeDetails, rawMockNodeDetails,
} from '../mock_data'; } from '../mock_data';
jest.mock('~/smart_interval');
jest.mock('ee/geo_nodes/event_hub');
const createComponent = () => { const createComponent = () => {
const Component = Vue.extend(appComponent); const Component = Vue.extend(appComponent);
const store = new GeoNodesStore(PRIMARY_VERSION.version, PRIMARY_VERSION.revision); const store = new GeoNodesStore(PRIMARY_VERSION.version, PRIMARY_VERSION.revision);
...@@ -97,7 +100,7 @@ describe('AppComponent', () => { ...@@ -97,7 +100,7 @@ describe('AppComponent', () => {
describe('fetchGeoNodes', () => { describe('fetchGeoNodes', () => {
it('calls service.getGeoNodes and sets response to the store on success', done => { it('calls service.getGeoNodes and sets response to the store on success', done => {
spyOn(vm.store, 'setNodes'); jest.spyOn(vm.store, 'setNodes');
vm.fetchGeoNodes() vm.fetchGeoNodes()
.then(() => { .then(() => {
...@@ -127,11 +130,9 @@ describe('AppComponent', () => { ...@@ -127,11 +130,9 @@ describe('AppComponent', () => {
describe('fetchNodeDetails', () => { describe('fetchNodeDetails', () => {
it('calls service.getGeoNodeDetails and sets response to the store on success', done => { it('calls service.getGeoNodeDetails and sets response to the store on success', done => {
mock.onGet(mockNode.statusPath).reply(200, rawMockNodeDetails); mock.onGet(mockNode.statusPath).reply(200, rawMockNodeDetails);
spyOn(vm.service, 'getGeoNodeDetails').and.callThrough();
vm.fetchNodeDetails(mockNode) vm.fetchNodeDetails(mockNode)
.then(() => { .then(() => {
expect(vm.service.getGeoNodeDetails).toHaveBeenCalled();
expect(Object.keys(vm.store.state.nodeDetails).length).not.toBe(0); expect(Object.keys(vm.store.state.nodeDetails).length).not.toBe(0);
expect(vm.store.state.nodeDetails['1']).toBeDefined(); expect(vm.store.state.nodeDetails['1']).toBeDefined();
}) })
...@@ -140,9 +141,8 @@ describe('AppComponent', () => { ...@@ -140,9 +141,8 @@ describe('AppComponent', () => {
}); });
it('emits `nodeDetailsLoaded` event with fake nodeDetails object on 404 failure', done => { it('emits `nodeDetailsLoaded` event with fake nodeDetails object on 404 failure', done => {
spyOn(eventHub, '$emit');
mock.onGet(mockNode.statusPath).reply(404, {}); mock.onGet(mockNode.statusPath).reply(404, {});
spyOn(vm.service, 'getGeoNodeDetails').and.callThrough(); jest.spyOn(vm.service, 'getGeoNodeDetails');
vm.fetchNodeDetails(mockNode) vm.fetchNodeDetails(mockNode)
.then(() => { .then(() => {
...@@ -158,9 +158,8 @@ describe('AppComponent', () => { ...@@ -158,9 +158,8 @@ describe('AppComponent', () => {
}); });
it('emits `nodeDetailsLoaded` event with fake nodeDetails object when a network error occurs', done => { it('emits `nodeDetailsLoaded` event with fake nodeDetails object when a network error occurs', done => {
spyOn(eventHub, '$emit');
mock.onGet(mockNode.statusPath).networkError(); mock.onGet(mockNode.statusPath).networkError();
spyOn(vm.service, 'getGeoNodeDetails').and.callThrough(); jest.spyOn(vm.service, 'getGeoNodeDetails');
vm.fetchNodeDetails(mockNode) vm.fetchNodeDetails(mockNode)
.then(() => { .then(() => {
...@@ -176,9 +175,8 @@ describe('AppComponent', () => { ...@@ -176,9 +175,8 @@ describe('AppComponent', () => {
}); });
it('emits `nodeDetailsLoaded` event with fake nodeDetails object when a timeout occurs', done => { it('emits `nodeDetailsLoaded` event with fake nodeDetails object when a timeout occurs', done => {
spyOn(eventHub, '$emit');
mock.onGet(mockNode.statusPath).timeout(); mock.onGet(mockNode.statusPath).timeout();
spyOn(vm.service, 'getGeoNodeDetails').and.callThrough(); jest.spyOn(vm.service, 'getGeoNodeDetails');
vm.fetchNodeDetails(mockNode) vm.fetchNodeDetails(mockNode)
.then(() => { .then(() => {
...@@ -201,7 +199,7 @@ describe('AppComponent', () => { ...@@ -201,7 +199,7 @@ describe('AppComponent', () => {
expect(node.nodeActionActive).toBe(true); expect(node.nodeActionActive).toBe(true);
return [200]; return [200];
}); });
spyOn(vm.service, 'repairNode').and.callThrough(); jest.spyOn(vm.service, 'repairNode');
vm.repairNode(node) vm.repairNode(node)
.then(() => { .then(() => {
...@@ -222,7 +220,7 @@ describe('AppComponent', () => { ...@@ -222,7 +220,7 @@ describe('AppComponent', () => {
expect(node.nodeActionActive).toBe(true); expect(node.nodeActionActive).toBe(true);
return [500]; return [500];
}); });
spyOn(vm.service, 'repairNode').and.callThrough(); jest.spyOn(vm.service, 'repairNode');
vm.repairNode(node) vm.repairNode(node)
.then(() => { .then(() => {
...@@ -250,7 +248,7 @@ describe('AppComponent', () => { ...@@ -250,7 +248,7 @@ describe('AppComponent', () => {
}, },
]; ];
}); });
spyOn(vm.service, 'toggleNode').and.callThrough(); jest.spyOn(vm.service, 'toggleNode');
node.enabled = false; node.enabled = false;
vm.toggleNode(node) vm.toggleNode(node)
...@@ -269,7 +267,7 @@ describe('AppComponent', () => { ...@@ -269,7 +267,7 @@ describe('AppComponent', () => {
expect(node.nodeActionActive).toBe(true); expect(node.nodeActionActive).toBe(true);
return [500]; return [500];
}); });
spyOn(vm.service, 'toggleNode').and.callThrough(); jest.spyOn(vm.service, 'toggleNode');
node.enabled = false; node.enabled = false;
vm.toggleNode(node) vm.toggleNode(node)
...@@ -293,8 +291,8 @@ describe('AppComponent', () => { ...@@ -293,8 +291,8 @@ describe('AppComponent', () => {
expect(node.nodeActionActive).toBe(true); expect(node.nodeActionActive).toBe(true);
return [200]; return [200];
}); });
spyOn(vm.service, 'removeNode').and.callThrough(); jest.spyOn(vm.service, 'removeNode');
spyOn(vm.store, 'removeNode').and.stub(); jest.spyOn(vm.store, 'removeNode');
vm.removeNode(node) vm.removeNode(node)
.then(() => { .then(() => {
...@@ -314,8 +312,8 @@ describe('AppComponent', () => { ...@@ -314,8 +312,8 @@ describe('AppComponent', () => {
expect(node.nodeActionActive).toBe(true); expect(node.nodeActionActive).toBe(true);
return [500]; return [500];
}); });
spyOn(vm.service, 'removeNode').and.callThrough(); jest.spyOn(vm.service, 'removeNode');
spyOn(vm.store, 'removeNode').and.stub(); jest.spyOn(vm.store, 'removeNode');
vm.removeNode(node) vm.removeNode(node)
.then(() => { .then(() => {
...@@ -334,8 +332,8 @@ describe('AppComponent', () => { ...@@ -334,8 +332,8 @@ describe('AppComponent', () => {
it('calls `toggleNode` and `hideNodeActionModal` when `targetNodeActionType` is `toggle`', () => { it('calls `toggleNode` and `hideNodeActionModal` when `targetNodeActionType` is `toggle`', () => {
vm.targetNode = { ...mockNode }; vm.targetNode = { ...mockNode };
vm.targetNodeActionType = NODE_ACTIONS.TOGGLE; vm.targetNodeActionType = NODE_ACTIONS.TOGGLE;
spyOn(vm, 'hideNodeActionModal'); jest.spyOn(vm, 'hideNodeActionModal');
spyOn(vm, 'toggleNode').and.stub(); jest.spyOn(vm, 'toggleNode');
vm.handleNodeAction(); vm.handleNodeAction();
...@@ -346,8 +344,8 @@ describe('AppComponent', () => { ...@@ -346,8 +344,8 @@ describe('AppComponent', () => {
it('calls `removeNode` and `hideNodeActionModal` when `targetNodeActionType` is `remove`', () => { it('calls `removeNode` and `hideNodeActionModal` when `targetNodeActionType` is `remove`', () => {
vm.targetNode = { ...mockNode }; vm.targetNode = { ...mockNode };
vm.targetNodeActionType = NODE_ACTIONS.REMOVE; vm.targetNodeActionType = NODE_ACTIONS.REMOVE;
spyOn(vm, 'hideNodeActionModal'); jest.spyOn(vm, 'hideNodeActionModal');
spyOn(vm, 'removeNode').and.stub(); jest.spyOn(vm, 'removeNode');
vm.handleNodeAction(); vm.handleNodeAction();
...@@ -370,7 +368,7 @@ describe('AppComponent', () => { ...@@ -370,7 +368,7 @@ describe('AppComponent', () => {
modalMessage = 'Foobar message'; modalMessage = 'Foobar message';
modalActionLabel = 'Disable'; modalActionLabel = 'Disable';
modalTitle = 'Test title'; modalTitle = 'Test title';
rootEmit = spyOn(vm.$root, '$emit'); rootEmit = jest.spyOn(vm.$root, '$emit');
}); });
it('sets target node and modal config props on component', () => { it('sets target node and modal config props on component', () => {
...@@ -407,7 +405,7 @@ describe('AppComponent', () => { ...@@ -407,7 +405,7 @@ describe('AppComponent', () => {
it('calls toggleNode when actionType is `toggle` and node.enabled is `false`', () => { it('calls toggleNode when actionType is `toggle` and node.enabled is `false`', () => {
node.enabled = false; node.enabled = false;
spyOn(vm, 'toggleNode').and.stub(); jest.spyOn(vm, 'toggleNode');
vm.showNodeActionModal({ vm.showNodeActionModal({
actionType: NODE_ACTIONS.TOGGLE, actionType: NODE_ACTIONS.TOGGLE,
...@@ -437,7 +435,7 @@ describe('AppComponent', () => { ...@@ -437,7 +435,7 @@ describe('AppComponent', () => {
describe('hideNodeActionModal', () => { describe('hideNodeActionModal', () => {
it('emits `bv::hide::modal`', () => { it('emits `bv::hide::modal`', () => {
const rootEmit = spyOn(vm.$root, '$emit'); const rootEmit = jest.spyOn(vm.$root, '$emit');
vm.hideNodeActionModal(); vm.hideNodeActionModal();
expect(rootEmit).toHaveBeenCalledWith('bv::hide::modal', vm.modalId); expect(rootEmit).toHaveBeenCalledWith('bv::hide::modal', vm.modalId);
...@@ -447,7 +445,6 @@ describe('AppComponent', () => { ...@@ -447,7 +445,6 @@ describe('AppComponent', () => {
describe('created', () => { describe('created', () => {
it('binds event handler for `pollNodeDetails`', () => { it('binds event handler for `pollNodeDetails`', () => {
spyOn(eventHub, '$on');
const vmX = createComponent(); const vmX = createComponent();
expect(eventHub.$on).toHaveBeenCalledWith('pollNodeDetails', jasmine.any(Function)); expect(eventHub.$on).toHaveBeenCalledWith('pollNodeDetails', jasmine.any(Function));
...@@ -459,7 +456,6 @@ describe('AppComponent', () => { ...@@ -459,7 +456,6 @@ describe('AppComponent', () => {
describe('beforeDestroy', () => { describe('beforeDestroy', () => {
it('unbinds event handler for `pollNodeDetails`', () => { it('unbinds event handler for `pollNodeDetails`', () => {
spyOn(eventHub, '$off');
const vmX = createComponent(); const vmX = createComponent();
vmX.$destroy(); vmX.$destroy();
......
import Vue from 'vue'; import Vue from 'vue';
import geoNodeActionsComponent from 'ee/geo_nodes/components/geo_node_actions.vue'; import geoNodeActionsComponent from 'ee/geo_nodes/components/geo_node_actions.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
import eventHub from 'ee/geo_nodes/event_hub'; import eventHub from 'ee/geo_nodes/event_hub';
import { NODE_ACTIONS } from 'ee/geo_nodes/constants'; import { NODE_ACTIONS } from 'ee/geo_nodes/constants';
import { mockNodes } from '../mock_data'; import { mockNodes } from '../mock_data';
jest.mock('ee/geo_nodes/event_hub');
const createComponent = ( const createComponent = (
node = mockNodes[0], node = mockNodes[0],
nodeEditAllowed = true, nodeEditAllowed = true,
...@@ -68,7 +70,6 @@ describe('GeoNodeActionsComponent', () => { ...@@ -68,7 +70,6 @@ describe('GeoNodeActionsComponent', () => {
describe('methods', () => { describe('methods', () => {
describe('onToggleNode', () => { describe('onToggleNode', () => {
it('emits showNodeActionModal with actionType `toggle`, node reference, modalMessage, modalActionLabel, and modalTitle', () => { it('emits showNodeActionModal with actionType `toggle`, node reference, modalMessage, modalActionLabel, and modalTitle', () => {
spyOn(eventHub, '$emit');
vm.onToggleNode(); vm.onToggleNode();
expect(eventHub.$emit).toHaveBeenCalledWith('showNodeActionModal', { expect(eventHub.$emit).toHaveBeenCalledWith('showNodeActionModal', {
...@@ -83,7 +84,6 @@ describe('GeoNodeActionsComponent', () => { ...@@ -83,7 +84,6 @@ describe('GeoNodeActionsComponent', () => {
describe('onRemovePrimaryNode', () => { describe('onRemovePrimaryNode', () => {
it('emits showNodeActionModal with actionType `remove`, node reference, modalKind, modalMessage, modalActionLabel, and modalTitle', () => { it('emits showNodeActionModal with actionType `remove`, node reference, modalKind, modalMessage, modalActionLabel, and modalTitle', () => {
spyOn(eventHub, '$emit');
vm.onRemovePrimaryNode(); vm.onRemovePrimaryNode();
expect(eventHub.$emit).toHaveBeenCalledWith('showNodeActionModal', { expect(eventHub.$emit).toHaveBeenCalledWith('showNodeActionModal', {
...@@ -100,7 +100,6 @@ describe('GeoNodeActionsComponent', () => { ...@@ -100,7 +100,6 @@ describe('GeoNodeActionsComponent', () => {
describe('onRemoveSecondaryNode', () => { describe('onRemoveSecondaryNode', () => {
it('emits showNodeActionModal with actionType `remove`, node reference, modalKind, modalMessage, modalActionLabel, and modalTitle', () => { it('emits showNodeActionModal with actionType `remove`, node reference, modalKind, modalMessage, modalActionLabel, and modalTitle', () => {
spyOn(eventHub, '$emit');
vm.onRemoveSecondaryNode(); vm.onRemoveSecondaryNode();
expect(eventHub.$emit).toHaveBeenCalledWith('showNodeActionModal', { expect(eventHub.$emit).toHaveBeenCalledWith('showNodeActionModal', {
...@@ -117,7 +116,6 @@ describe('GeoNodeActionsComponent', () => { ...@@ -117,7 +116,6 @@ describe('GeoNodeActionsComponent', () => {
describe('onRepairNode', () => { describe('onRepairNode', () => {
it('emits `repairNode` event with node reference', () => { it('emits `repairNode` event with node reference', () => {
spyOn(eventHub, '$emit');
vm.onRepairNode(); vm.onRepairNode();
expect(eventHub.$emit).toHaveBeenCalledWith('repairNode', vm.node); expect(eventHub.$emit).toHaveBeenCalledWith('repairNode', vm.node);
......
...@@ -2,7 +2,7 @@ import Vue from 'vue'; ...@@ -2,7 +2,7 @@ import Vue from 'vue';
import geoNodeDetailItemComponent from 'ee/geo_nodes/components/geo_node_detail_item.vue'; import geoNodeDetailItemComponent from 'ee/geo_nodes/components/geo_node_detail_item.vue';
import { VALUE_TYPE, CUSTOM_TYPE } from 'ee/geo_nodes/constants'; import { VALUE_TYPE, CUSTOM_TYPE } from 'ee/geo_nodes/constants';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
import { rawMockNodeDetails } from '../mock_data'; import { rawMockNodeDetails } from '../mock_data';
const createComponent = config => { const createComponent = config => {
......
import Vue from 'vue'; import Vue from 'vue';
import geoNodeDetailsComponent from 'ee/geo_nodes/components/geo_node_details.vue'; import geoNodeDetailsComponent from 'ee/geo_nodes/components/geo_node_details.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
import { mockNode, mockNodeDetails } from '../mock_data'; import { mockNode, mockNodeDetails } from '../mock_data';
const createComponent = ({ const createComponent = ({
......
import Vue from 'vue'; import Vue from 'vue';
import geoNodeEventStatusComponent from 'ee/geo_nodes/components/geo_node_event_status.vue'; import geoNodeEventStatusComponent from 'ee/geo_nodes/components/geo_node_event_status.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
import { mockNodeDetails } from '../mock_data'; import { mockNodeDetails } from '../mock_data';
const createComponent = ({ const createComponent = ({
......
import Vue from 'vue'; import Vue from 'vue';
import GeoNodeHeaderComponent from 'ee/geo_nodes/components/geo_node_header.vue'; import GeoNodeHeaderComponent from 'ee/geo_nodes/components/geo_node_header.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
import { mockNode, mockNodeDetails } from '../mock_data'; import { mockNode, mockNodeDetails } from '../mock_data';
const createComponent = ({ const createComponent = ({
......
...@@ -2,7 +2,7 @@ import Vue from 'vue'; ...@@ -2,7 +2,7 @@ import Vue from 'vue';
import geoNodeHealthStatusComponent from 'ee/geo_nodes/components/geo_node_health_status.vue'; import geoNodeHealthStatusComponent from 'ee/geo_nodes/components/geo_node_health_status.vue';
import { HEALTH_STATUS_ICON, HEALTH_STATUS_CLASS } from 'ee/geo_nodes/constants'; import { HEALTH_STATUS_ICON, HEALTH_STATUS_CLASS } from 'ee/geo_nodes/constants';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
import { mockNodeDetails } from '../mock_data'; import { mockNodeDetails } from '../mock_data';
const createComponent = (status = mockNodeDetails.health) => { const createComponent = (status = mockNodeDetails.health) => {
......
...@@ -2,9 +2,11 @@ import Vue from 'vue'; ...@@ -2,9 +2,11 @@ import Vue from 'vue';
import geoNodeItemComponent from 'ee/geo_nodes/components/geo_node_item.vue'; import geoNodeItemComponent from 'ee/geo_nodes/components/geo_node_item.vue';
import eventHub from 'ee/geo_nodes/event_hub'; import eventHub from 'ee/geo_nodes/event_hub';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
import { mockNode, mockNodeDetails } from '../mock_data'; import { mockNode, mockNodeDetails } from '../mock_data';
jest.mock('ee/geo_nodes/event_hub');
const createComponent = (node = mockNode) => { const createComponent = (node = mockNode) => {
const Component = Vue.extend(geoNodeItemComponent); const Component = Vue.extend(geoNodeItemComponent);
...@@ -45,6 +47,7 @@ describe('GeoNodeItemComponent', () => { ...@@ -45,6 +47,7 @@ describe('GeoNodeItemComponent', () => {
beforeEach(() => { beforeEach(() => {
// Altered mock data for secure URL // Altered mock data for secure URL
httpsNode = Object.assign({}, mockNode, { httpsNode = Object.assign({}, mockNode, {
id: mockNodeDetails.id,
url: 'https://127.0.0.1:3001/', url: 'https://127.0.0.1:3001/',
}); });
vmHttps = createComponent(httpsNode); vmHttps = createComponent(httpsNode);
...@@ -56,23 +59,24 @@ describe('GeoNodeItemComponent', () => { ...@@ -56,23 +59,24 @@ describe('GeoNodeItemComponent', () => {
describe('showNodeDetails', () => { describe('showNodeDetails', () => {
it('returns `false` if Node details are still loading', () => { it('returns `false` if Node details are still loading', () => {
vm.isNodeDetailsLoading = true; vmHttps.isNodeDetailsLoading = true;
expect(vm.showNodeDetails).toBeFalsy(); expect(vmHttps.showNodeDetails).toBeFalsy();
}); });
it('returns `false` if Node details failed to load', () => { it('returns `false` if Node details failed to load', () => {
vm.isNodeDetailsLoading = false; vmHttps.isNodeDetailsLoading = false;
vm.isNodeDetailsFailed = true; vmHttps.isNodeDetailsFailed = true;
expect(vm.showNodeDetails).toBeFalsy(); expect(vmHttps.showNodeDetails).toBeFalsy();
}); });
it('returns `true` if Node details loaded', () => { it('returns `true` if Node details loaded', () => {
vm.isNodeDetailsLoading = false; vmHttps.handleNodeDetails(mockNodeDetails);
vm.isNodeDetailsFailed = false; vmHttps.isNodeDetailsLoading = false;
vmHttps.isNodeDetailsFailed = false;
expect(vm.showNodeDetails).toBeTruthy(); expect(vmHttps.showNodeDetails).toBeTruthy();
}); });
}); });
}); });
...@@ -107,8 +111,6 @@ describe('GeoNodeItemComponent', () => { ...@@ -107,8 +111,6 @@ describe('GeoNodeItemComponent', () => {
describe('handleMounted', () => { describe('handleMounted', () => {
it('emits `pollNodeDetails` event and passes node ID', () => { it('emits `pollNodeDetails` event and passes node ID', () => {
spyOn(eventHub, '$emit');
vm.handleMounted(); vm.handleMounted();
expect(eventHub.$emit).toHaveBeenCalledWith('pollNodeDetails', vm.node); expect(eventHub.$emit).toHaveBeenCalledWith('pollNodeDetails', vm.node);
...@@ -118,8 +120,6 @@ describe('GeoNodeItemComponent', () => { ...@@ -118,8 +120,6 @@ describe('GeoNodeItemComponent', () => {
describe('created', () => { describe('created', () => {
it('binds `nodeDetailsLoaded` event handler', () => { it('binds `nodeDetailsLoaded` event handler', () => {
spyOn(eventHub, '$on');
const vmX = createComponent(); const vmX = createComponent();
expect(eventHub.$on).toHaveBeenCalledWith('nodeDetailsLoaded', jasmine.any(Function)); expect(eventHub.$on).toHaveBeenCalledWith('nodeDetailsLoaded', jasmine.any(Function));
...@@ -129,8 +129,6 @@ describe('GeoNodeItemComponent', () => { ...@@ -129,8 +129,6 @@ describe('GeoNodeItemComponent', () => {
describe('beforeDestroy', () => { describe('beforeDestroy', () => {
it('unbinds `nodeDetailsLoaded` event handler', () => { it('unbinds `nodeDetailsLoaded` event handler', () => {
spyOn(eventHub, '$off');
const vmX = createComponent(); const vmX = createComponent();
vmX.$destroy(); vmX.$destroy();
......
import Vue from 'vue'; import Vue from 'vue';
import geoNodeSyncSettingsComponent from 'ee/geo_nodes/components/geo_node_sync_settings.vue'; import geoNodeSyncSettingsComponent from 'ee/geo_nodes/components/geo_node_sync_settings.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
import { mockNodeDetails } from '../mock_data'; import { mockNodeDetails } from '../mock_data';
const createComponent = ( const createComponent = (
......
import Vue from 'vue'; import Vue from 'vue';
import geoNodesListComponent from 'ee/geo_nodes/components/geo_nodes_list.vue'; import geoNodesListComponent from 'ee/geo_nodes/components/geo_nodes_list.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
import { mockNodes } from '../mock_data'; import { mockNodes } from '../mock_data';
const createComponent = () => { const createComponent = () => {
......
import Vue from 'vue'; import Vue from 'vue';
import NodeDetailsSectionMainComponent from 'ee/geo_nodes/components/node_detail_sections/node_details_section_main.vue'; import NodeDetailsSectionMainComponent from 'ee/geo_nodes/components/node_detail_sections/node_details_section_main.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
import { mockNode, mockNodeDetails } from 'ee_spec/geo_nodes/mock_data'; import { mockNode, mockNodeDetails } from '../../mock_data';
const MOCK_VERSION_TEXT = `${mockNodeDetails.version} (${mockNodeDetails.revision})`; const MOCK_VERSION_TEXT = `${mockNodeDetails.version} (${mockNodeDetails.revision})`;
......
import Vue from 'vue'; import Vue from 'vue';
import NodeDetailsSectionOtherComponent from 'ee/geo_nodes/components/node_detail_sections/node_details_section_other.vue'; import NodeDetailsSectionOtherComponent from 'ee/geo_nodes/components/node_detail_sections/node_details_section_other.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
import { mockNode, mockNodeDetails } from 'ee_spec/geo_nodes/mock_data'; import { mockNode, mockNodeDetails } from '../../mock_data';
import { numberToHumanSize } from '~/lib/utils/number_utils'; import { numberToHumanSize } from '~/lib/utils/number_utils';
const createComponent = ( const createComponent = (
......
import Vue from 'vue'; import Vue from 'vue';
import NodeDetailsSectionSyncComponent from 'ee/geo_nodes/components/node_detail_sections/node_details_section_sync.vue'; import NodeDetailsSectionSyncComponent from 'ee/geo_nodes/components/node_detail_sections/node_details_section_sync.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
import { mockNodeDetails } from 'ee_spec/geo_nodes/mock_data'; import { mockNodeDetails } from '../../mock_data';
const createComponent = (nodeDetails = Object.assign({}, mockNodeDetails)) => { const createComponent = (nodeDetails = Object.assign({}, mockNodeDetails)) => {
const Component = Vue.extend(NodeDetailsSectionSyncComponent); const Component = Vue.extend(NodeDetailsSectionSyncComponent);
......
import Vue from 'vue'; import Vue from 'vue';
import NodeDetailsSectionVerificationComponent from 'ee/geo_nodes/components/node_detail_sections/node_details_section_verification.vue'; import NodeDetailsSectionVerificationComponent from 'ee/geo_nodes/components/node_detail_sections/node_details_section_verification.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
import { mockNodeDetails } from 'ee_spec/geo_nodes/mock_data'; import { mockNodeDetails } from '../../mock_data';
const createComponent = ({ nodeDetails = mockNodeDetails, nodeTypePrimary = false }) => { const createComponent = ({ nodeDetails = mockNodeDetails, nodeTypePrimary = false }) => {
const Component = Vue.extend(NodeDetailsSectionVerificationComponent); const Component = Vue.extend(NodeDetailsSectionVerificationComponent);
......
import Vue from 'vue'; import Vue from 'vue';
import SectionRevealButtonComponent from 'ee/geo_nodes/components/node_detail_sections/section_reveal_button.vue'; import SectionRevealButtonComponent from 'ee/geo_nodes/components/node_detail_sections/section_reveal_button.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
const createComponent = (buttonTitle = 'Foo button') => { const createComponent = (buttonTitle = 'Foo button') => {
const Component = Vue.extend(SectionRevealButtonComponent); const Component = Vue.extend(SectionRevealButtonComponent);
...@@ -52,7 +52,7 @@ describe('SectionRevealButton', () => { ...@@ -52,7 +52,7 @@ describe('SectionRevealButton', () => {
}); });
it('emits `toggleButton` event on component', () => { it('emits `toggleButton` event on component', () => {
spyOn(vm, '$emit'); jest.spyOn(vm, '$emit');
vm.onClickButton(); vm.onClickButton();
expect(vm.$emit).toHaveBeenCalledWith('toggleButton', vm.toggleState); expect(vm.$emit).toHaveBeenCalledWith('toggleButton', vm.toggleState);
......
...@@ -3,7 +3,7 @@ import Vue from 'vue'; ...@@ -3,7 +3,7 @@ import Vue from 'vue';
import DetailsSectionMixin from 'ee/geo_nodes/mixins/details_section_mixin'; import DetailsSectionMixin from 'ee/geo_nodes/mixins/details_section_mixin';
import { STATUS_DELAY_THRESHOLD_MS } from 'ee/geo_nodes/constants'; import { STATUS_DELAY_THRESHOLD_MS } from 'ee/geo_nodes/constants';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
import { mockNodeDetails } from '../mock_data'; import { mockNodeDetails } from '../mock_data';
const createComponent = (nodeDetails = mockNodeDetails) => { const createComponent = (nodeDetails = mockNodeDetails) => {
...@@ -12,7 +12,9 @@ const createComponent = (nodeDetails = mockNodeDetails) => { ...@@ -12,7 +12,9 @@ const createComponent = (nodeDetails = mockNodeDetails) => {
data() { data() {
return { nodeDetails }; return { nodeDetails };
}, },
template: '<div></div>', render(h) {
return h('div');
},
}); });
return mountComponent(Component); return mountComponent(Component);
......
...@@ -3,6 +3,8 @@ import axios from '~/lib/utils/axios_utils'; ...@@ -3,6 +3,8 @@ import axios from '~/lib/utils/axios_utils';
import { NODE_DETAILS_PATH } from '../mock_data'; import { NODE_DETAILS_PATH } from '../mock_data';
jest.mock('axios');
describe('GeoNodesService', () => { describe('GeoNodesService', () => {
let service; let service;
...@@ -12,7 +14,6 @@ describe('GeoNodesService', () => { ...@@ -12,7 +14,6 @@ describe('GeoNodesService', () => {
describe('getGeoNodes', () => { describe('getGeoNodes', () => {
it('returns axios instance for Geo nodes path', () => { it('returns axios instance for Geo nodes path', () => {
spyOn(axios, 'get').and.stub();
service.getGeoNodes(); service.getGeoNodes();
expect(axios.get).toHaveBeenCalledWith(service.geoNodesPath); expect(axios.get).toHaveBeenCalledWith(service.geoNodesPath);
...@@ -21,7 +22,6 @@ describe('GeoNodesService', () => { ...@@ -21,7 +22,6 @@ describe('GeoNodesService', () => {
describe('getGeoNodeDetails', () => { describe('getGeoNodeDetails', () => {
it('returns axios instance for Geo node details path', () => { it('returns axios instance for Geo node details path', () => {
spyOn(axios, 'get').and.stub();
service.getGeoNodeDetails(2); service.getGeoNodeDetails(2);
expect(axios.get).toHaveBeenCalled(); expect(axios.get).toHaveBeenCalled();
......
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