summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSukanya Pandey <sukapan1@in.ibm.com>2020-03-26 14:40:32 +0300
committerDerick Montague <derick.montague@ibm.com>2020-04-07 19:36:06 +0300
commit98059c92dfc1b6f30ffbe02f4ae01e7cba30f8e9 (patch)
treec3010b9e9f6244cdfad751067254eb61fd174850 /tests
parent1f9ed4c310fe029b960b2ebf9c32e57c5d1498f3 (diff)
downloadwebui-vue-98059c92dfc1b6f30ffbe02f4ae01e7cba30f8e9.tar.xz
Add spec files for the components
- AppHeader.js - AppNavigation.js Signed-off-by: Sukanya Pandey <sukapan1@in.ibm.com> Change-Id: I55bbd16349dcf134b68fe33ba7cc26f29a98cfc7
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/AppHeader.spec.js62
-rw-r--r--tests/unit/AppNavigation.spec.js37
2 files changed, 99 insertions, 0 deletions
diff --git a/tests/unit/AppHeader.spec.js b/tests/unit/AppHeader.spec.js
new file mode 100644
index 00000000..6dea960b
--- /dev/null
+++ b/tests/unit/AppHeader.spec.js
@@ -0,0 +1,62 @@
+import { mount } from '@vue/test-utils';
+import Vue from 'vue';
+import AppHeader from '@/components/AppHeader';
+import $store from '@/store';
+import { BootstrapVue } from 'bootstrap-vue';
+
+describe('AppHeader.vue', () => {
+ let wrapper;
+ let spy;
+ Vue.use(BootstrapVue);
+
+ wrapper = mount(AppHeader, {
+ mocks: {
+ $t: key => key,
+ $store
+ }
+ });
+
+ beforeEach(() => {
+ spy = sinon.spy($store.dispatch);
+ });
+
+ describe('Component exists', () => {
+ it('should check if AppHeader exists', async () => {
+ expect(wrapper.exists());
+ });
+ });
+
+ describe('AppHeader methods', () => {
+ it('should call getHostInfo and dispatch global/getHostStatus', async () => {
+ wrapper.vm.getHostInfo();
+ spy('global/getHostStatus');
+ expect(spy).to.have.been.calledWith('global/getHostStatus');
+ });
+
+ it('should call getEvents and dispatch eventLog/getEventLogData', async () => {
+ wrapper.vm.getEvents();
+ spy('eventLog/getEventLogData');
+ expect(spy).to.have.been.calledWith('eventLog/getEventLogData');
+ });
+
+ it('should call refresh and emit refresh', async () => {
+ spy = sinon.spy(wrapper.vm.$emit);
+ wrapper.vm.refresh();
+ spy('refresh');
+ expect(spy).to.have.been.calledWith('refresh');
+ });
+
+ it('should call logout and dispatch authentication/logout', async () => {
+ wrapper.vm.logout();
+ spy('authentication/logout');
+ expect(spy).to.have.been.calledWith('authentication/logout');
+ });
+
+ it('should call toggleNavigation and dispatch toggle:navigation', async () => {
+ spy = sinon.spy(wrapper.vm.$root.$emit);
+ wrapper.vm.toggleNavigation();
+ spy('toggle:navigation');
+ expect(spy).to.have.been.calledWith('toggle:navigation');
+ });
+ });
+});
diff --git a/tests/unit/AppNavigation.spec.js b/tests/unit/AppNavigation.spec.js
new file mode 100644
index 00000000..3424f698
--- /dev/null
+++ b/tests/unit/AppNavigation.spec.js
@@ -0,0 +1,37 @@
+import { mount } from '@vue/test-utils';
+import AppNavigation from '@/components/AppNavigation';
+import Vue from 'vue';
+import { BootstrapVue } from 'bootstrap-vue';
+
+describe('AppNavigation.vue', () => {
+ let wrapper;
+ Vue.use(BootstrapVue);
+
+ wrapper = mount(AppNavigation, {
+ mocks: {
+ $t: key => key
+ }
+ });
+
+ describe('Component exists', () => {
+ it('should check if AppNavigation exists', async () => {
+ expect(wrapper.exists());
+ });
+ });
+
+ describe('Methods', () => {
+ describe('toggleIsOpen method', () => {
+ it('should call toggleIsOpen and toggle isNavigationOpen to false', async () => {
+ wrapper.vm.isNavigationOpen = true;
+ wrapper.vm.toggleIsOpen();
+ expect(wrapper.vm.isNavigationOpen).to.be.false;
+ });
+
+ it('should call toggleIsOpen and toggle isNavigationOpen to true', async () => {
+ wrapper.vm.isNavigationOpen = false;
+ wrapper.vm.toggleIsOpen();
+ expect(wrapper.vm.isNavigationOpen).to.be.true;
+ });
+ });
+ });
+});