From 8c753a3caa5f3588778a9b773fb92892ce2cac25 Mon Sep 17 00:00:00 2001 From: xidedix Date: Fri, 19 Oct 2018 13:58:30 +0200 Subject: [PATCH 1/7] refactor: extract random() to shared/utils --- src/shared/utils.js | 3 +++ src/views/dashboard/MainChartExample.vue | 5 +---- 2 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 src/shared/utils.js diff --git a/src/shared/utils.js b/src/shared/utils.js new file mode 100644 index 00000000..e7eeb133 --- /dev/null +++ b/src/shared/utils.js @@ -0,0 +1,3 @@ +export function random (min, max) { + return Math.floor(Math.random() * (max - min + 1) + min) +} diff --git a/src/views/dashboard/MainChartExample.vue b/src/views/dashboard/MainChartExample.vue index 6cc712a2..fe6cdb1f 100644 --- a/src/views/dashboard/MainChartExample.vue +++ b/src/views/dashboard/MainChartExample.vue @@ -2,10 +2,7 @@ import { Line } from 'vue-chartjs' import { getStyle, hexToRgba } from '@coreui/coreui/dist/js/coreui-utilities' import { CustomTooltips } from '@coreui/coreui-plugin-chartjs-custom-tooltips' - -function random (min, max) { - return Math.floor(Math.random() * (max - min + 1) + min) -} +import { random } from '@/shared/utils' export default { extends: Line, From ba8ce87fcabd76c9dab3a6def95bcf878d619b09 Mon Sep 17 00:00:00 2001 From: xidedix Date: Fri, 19 Oct 2018 14:00:40 +0200 Subject: [PATCH 2/7] refactor: views cleanup --- src/containers/DefaultContainer.vue | 2 +- src/views/base/Popovers.vue | 4 ++-- src/views/base/ProgressBars.vue | 13 ++++++++----- src/views/base/Switches.vue | 5 ----- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/containers/DefaultContainer.vue b/src/containers/DefaultContainer.vue index 3579dfb0..f227a39a 100644 --- a/src/containers/DefaultContainer.vue +++ b/src/containers/DefaultContainer.vue @@ -68,7 +68,7 @@ import DefaultAside from './DefaultAside' import DefaultHeaderDropdownAccnt from './DefaultHeaderDropdownAccnt' export default { - name: 'full', + name: 'DefaultContainer', components: { AsideToggler, AppHeader, diff --git a/src/views/base/Popovers.vue b/src/views/base/Popovers.vue index 17db010e..04362fbb 100644 --- a/src/views/base/Popovers.vue +++ b/src/views/base/Popovers.vue @@ -42,10 +42,10 @@ - + {{ placement }} - { + this.bars.forEach(bar => { + bar.value = 25 + (Math.random() * 75) + }) + }, 2000) } }, mounted () { - this.timer = setInterval(() => { - this.bars.forEach(bar => { - bar.value = 25 + (Math.random() * 75) - }) - }, 2000) + this.setClock() }, beforeDestroy () { clearInterval(this.timer) diff --git a/src/views/base/Switches.vue b/src/views/base/Switches.vue index 32888775..4c32da35 100644 --- a/src/views/base/Switches.vue +++ b/src/views/base/Switches.vue @@ -417,11 +417,6 @@ export default { components: { cSwitch }, - computed: { - icon (icon) { - return icon - } - }, data: () => { return { fields: [ From d6cfdaa88cbe5a244577467629350244f49917aa Mon Sep 17 00:00:00 2001 From: xidedix Date: Fri, 19 Oct 2018 14:35:53 +0200 Subject: [PATCH 3/7] refactor: views Tables, Table - refactor: extract shuffleArray() to shared/utils - refactor: Tables/Table pass items as props to c-table --- src/shared/utils.js | 14 +++++++ src/views/base/Table.vue | 82 ++++++++++++++------------------------- src/views/base/Tables.vue | 68 ++++++++++++++++++++++++++------ 3 files changed, 101 insertions(+), 63 deletions(-) diff --git a/src/shared/utils.js b/src/shared/utils.js index e7eeb133..80999d08 100644 --- a/src/shared/utils.js +++ b/src/shared/utils.js @@ -1,3 +1,17 @@ export function random (min, max) { return Math.floor(Math.random() * (max - min + 1) + min) } + +/** + * Randomize array element order in-place. + * Using Durstenfeld shuffle algorithm. + */ +export const shuffleArray = (array) => { + for (let i = array.length - 1; i > 0; i--) { + let j = Math.floor(Math.random() * (i + 1)) + let temp = array[i] + array[i] = array[j] + array[j] = temp + } + return array +} diff --git a/src/views/base/Table.vue b/src/views/base/Table.vue index 7980d995..d940b225 100644 --- a/src/views/base/Table.vue +++ b/src/views/base/Table.vue @@ -1,33 +1,22 @@ From e5a3e32283ab0539de5e58eb2841d34f08e34d87 Mon Sep 17 00:00:00 2001 From: xidedix Date: Fri, 19 Oct 2018 14:42:30 +0200 Subject: [PATCH 4/7] tests(e2e): add some more test cases --- tests/e2e/specs/test.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/e2e/specs/test.js b/tests/e2e/specs/test.js index 4bab3dce..53d7e4ac 100644 --- a/tests/e2e/specs/test.js +++ b/tests/e2e/specs/test.js @@ -40,14 +40,14 @@ module.exports = { browser.click('body > div > header > button.d-none.d-lg-block.navbar-toggler', function (response) { console.log('response', typeof response) this.assert.ok(browser === this, 'Check if the context is right.') - this.assert.cssClassPresent('body', 'aside-menu-show') + this.assert.cssClassPresent('body', 'aside-menu-lg-show') }) browser.pause(500) browser.click('body > div > header > button.d-none.d-lg-block.navbar-toggler', function (response) { console.log('response', typeof response) - this.assert.cssClassNotPresent('body', 'aside-menu-show') + this.assert.cssClassNotPresent('body', 'aside-menu-lg-show') }) browser.pause(500) @@ -72,6 +72,7 @@ module.exports = { console.log('response', typeof response) this.assert.cssClassPresent('/html/body', 'sidebar-minimized') this.assert.cssClassPresent('/html/body', 'brand-minimized') + this.assert.cssProperty("/html/body/div/div/main", "margin-left", "50px"); }) .pause(500) .click('/html/body/div/div/div/button', function (response) { @@ -89,6 +90,7 @@ module.exports = { .click('/html/body/div/header/button[1]', function (response) { console.log('response', typeof response) this.assert.cssClassPresent('/html/body', 'sidebar-show') + this.assert.cssProperty("/html/body/div/div/main", "margin-left", "200px"); }) browser @@ -98,6 +100,16 @@ module.exports = { this.assert.cssClassNotPresent('/html/body', 'sidebar-show') }) + browser + .resizeWindow(500, 600) + .pause(500) + + .click('/html/body/div/header/button[1]', function (response) { + console.log('response', typeof response) + this.assert.cssClassPresent('/html/body', 'sidebar-show') + this.assert.cssProperty("/html/body/div/div/main", "margin-left", "0px"); + }) + browser .pause(5000) .end() From aa064d3bb0407a6e38f7c128ecf6b03dd5eac4f0 Mon Sep 17 00:00:00 2001 From: xidedix Date: Fri, 19 Oct 2018 14:48:07 +0200 Subject: [PATCH 5/7] tests(unit): add more test cases and snapshots --- tests/unit/Users.spec.js | 35 - .../{ => containers}/DefaultAside.spec.js | 5 + .../{ => containers}/DefaultContainer.spec.js | 11 +- .../DefaultHeaderDropdownAccnt.spec.js | 5 + .../__snapshots__/DefaultAside.spec.js.snap | 946 + .../DefaultContainer.spec.js.snap | 231 + .../DefaultHeaderDropdownAccnt.spec.js.snap | 243 + tests/unit/shared/classes.spec.js | 33 + tests/unit/shared/toggle-classes.spec.js | 22 + tests/unit/shared/utils.spec.js | 23 + tests/unit/{ => views}/Charts.spec.js | 6 +- tests/unit/{ => views}/Dashboard.spec.js | 13 + tests/unit/{ => views}/Widgets.spec.js | 4 + .../views/__snapshots__/Charts.spec.js.snap | 121 + .../__snapshots__/Dashboard.spec.js.snap | 1657 ++ .../views/__snapshots__/Widgets.spec.js.snap | 2032 +++ .../unit/{ => views/base}/Breadcrumbs.spec.js | 4 + tests/unit/{ => views/base}/Cards.spec.js | 4 + tests/unit/{ => views/base}/Carousels.spec.js | 10 + tests/unit/{ => views/base}/Collapses.spec.js | 4 + tests/unit/{ => views/base}/Forms.spec.js | 4 + .../unit/{ => views/base}/Jumbotrons.spec.js | 4 + .../unit/{ => views/base}/ListGroups.spec.js | 4 + tests/unit/{ => views/base}/Navbars.spec.js | 4 + tests/unit/{ => views/base}/Navs.spec.js | 4 + .../unit/{ => views/base}/Paginations.spec.js | 4 + tests/unit/{ => views/base}/Popovers.spec.js | 21 +- .../{ => views/base}/ProgressBars.spec.js | 16 +- tests/unit/{ => views/base}/Switches.spec.js | 6 +- tests/unit/{ => views/base}/Table.spec.js | 6 +- tests/unit/{ => views/base}/Tables.spec.js | 6 +- tests/unit/{ => views/base}/Tabs.spec.js | 6 +- tests/unit/{ => views/base}/Tooltips.spec.js | 21 +- .../__snapshots__/Breadcrumbs.spec.js.snap | 96 + .../base/__snapshots__/Cards.spec.js.snap | 842 + .../base/__snapshots__/Carousels.spec.js.snap | 256 + .../base/__snapshots__/Collapses.spec.js.snap | 583 + .../base/__snapshots__/Forms.spec.js.snap | 3544 ++++ .../__snapshots__/Jumbotrons.spec.js.snap | 242 + .../__snapshots__/ListGroups.spec.js.snap | 1188 ++ .../base/__snapshots__/Navbars.spec.js.snap | 590 + .../base/__snapshots__/Navs.spec.js.snap | 553 + .../__snapshots__/Paginations.spec.js.snap | 216 + .../base/__snapshots__/Popovers.spec.js.snap | 941 + .../__snapshots__/ProgressBars.spec.js.snap | 745 + .../base/__snapshots__/Switches.spec.js.snap | 3283 ++++ .../base/__snapshots__/Table.spec.js.snap | 40 + .../base/__snapshots__/Tables.spec.js.snap | 642 + .../base/__snapshots__/Tabs.spec.js.snap | 383 + .../base/__snapshots__/Tooltips.spec.js.snap | 451 + .../{ => views/buttons}/BrandButtons.spec.js | 4 + .../buttons}/ButtonDropdowns.spec.js | 4 + .../{ => views/buttons}/ButtonGroups.spec.js | 4 + .../buttons}/StandardButtons.spec.js | 4 + .../__snapshots__/BrandButtons.spec.js.snap | 2460 +++ .../ButtonDropdowns.spec.js.snap | 1486 ++ .../__snapshots__/ButtonGroups.spec.js.snap | 836 + .../StandardButtons.spec.js.snap | 4397 +++++ .../{ => views/icons}/CoreUIIcons.spec.js | 4 + tests/unit/{ => views/icons}/Flags.spec.js | 4 + .../{ => views/icons}/FontAwesome.spec.js | 4 + .../{ => views/icons}/SimpleLineIcons.spec.js | 4 + .../__snapshots__/CoreUIIcons.spec.js.snap | 1250 ++ .../icons/__snapshots__/Flags.spec.js.snap | 4290 +++++ .../__snapshots__/FontAwesome.spec.js.snap | 14258 ++++++++++++++++ .../SimpleLineIcons.spec.js.snap | 2417 +++ .../{ => views/notifications}/Alerts.spec.js | 10 + .../{ => views/notifications}/Badges.spec.js | 4 + .../{ => views/notifications}/Modals.spec.js | 4 + .../__snapshots__/Alerts.spec.js.snap | 479 + .../__snapshots__/Badges.spec.js.snap | 357 + .../__snapshots__/Modals.spec.js.snap | 309 + tests/unit/{ => views/pages}/Login.spec.js | 4 + tests/unit/{ => views/pages}/Page404.spec.js | 4 + tests/unit/{ => views/pages}/Page500.spec.js | 4 + tests/unit/{ => views/pages}/Register.spec.js | 4 + .../pages/__snapshots__/Login.spec.js.snap | 184 + .../pages/__snapshots__/Page404.spec.js.snap | 84 + .../pages/__snapshots__/Page500.spec.js.snap | 84 + .../pages/__snapshots__/Register.spec.js.snap | 208 + tests/unit/{ => views/theme}/Colors.spec.js | 4 + .../unit/{ => views/theme}/Typography.spec.js | 4 + .../theme/__snapshots__/Colors.spec.js.snap | 1387 ++ .../__snapshots__/Typography.spec.js.snap | 502 + tests/unit/{ => views/users}/User.spec.js | 16 + tests/unit/views/users/Users.spec.js | 65 + .../users/__snapshots__/User.spec.js.snap | 62 + .../users/__snapshots__/Users.spec.js.snap | 54 + 88 files changed, 55320 insertions(+), 49 deletions(-) delete mode 100644 tests/unit/Users.spec.js rename tests/unit/{ => containers}/DefaultAside.spec.js (59%) rename tests/unit/{ => containers}/DefaultContainer.spec.js (72%) rename tests/unit/{ => containers}/DefaultHeaderDropdownAccnt.spec.js (77%) create mode 100644 tests/unit/containers/__snapshots__/DefaultAside.spec.js.snap create mode 100644 tests/unit/containers/__snapshots__/DefaultContainer.spec.js.snap create mode 100644 tests/unit/containers/__snapshots__/DefaultHeaderDropdownAccnt.spec.js.snap create mode 100644 tests/unit/shared/classes.spec.js create mode 100644 tests/unit/shared/toggle-classes.spec.js create mode 100644 tests/unit/shared/utils.spec.js rename tests/unit/{ => views}/Charts.spec.js (72%) rename tests/unit/{ => views}/Dashboard.spec.js (62%) rename tests/unit/{ => views}/Widgets.spec.js (86%) create mode 100644 tests/unit/views/__snapshots__/Charts.spec.js.snap create mode 100644 tests/unit/views/__snapshots__/Dashboard.spec.js.snap create mode 100644 tests/unit/views/__snapshots__/Widgets.spec.js.snap rename tests/unit/{ => views/base}/Breadcrumbs.spec.js (89%) rename tests/unit/{ => views/base}/Cards.spec.js (88%) rename tests/unit/{ => views/base}/Carousels.spec.js (70%) rename tests/unit/{ => views/base}/Collapses.spec.js (89%) rename tests/unit/{ => views/base}/Forms.spec.js (88%) rename tests/unit/{ => views/base}/Jumbotrons.spec.js (85%) rename tests/unit/{ => views/base}/ListGroups.spec.js (85%) rename tests/unit/{ => views/base}/Navbars.spec.js (84%) rename tests/unit/{ => views/base}/Navs.spec.js (84%) rename tests/unit/{ => views/base}/Paginations.spec.js (88%) rename tests/unit/{ => views/base}/Popovers.spec.js (54%) rename tests/unit/{ => views/base}/ProgressBars.spec.js (67%) rename tests/unit/{ => views/base}/Switches.spec.js (84%) rename tests/unit/{ => views/base}/Table.spec.js (82%) rename tests/unit/{ => views/base}/Tables.spec.js (77%) rename tests/unit/{ => views/base}/Tabs.spec.js (84%) rename tests/unit/{ => views/base}/Tooltips.spec.js (56%) create mode 100644 tests/unit/views/base/__snapshots__/Breadcrumbs.spec.js.snap create mode 100644 tests/unit/views/base/__snapshots__/Cards.spec.js.snap create mode 100644 tests/unit/views/base/__snapshots__/Carousels.spec.js.snap create mode 100644 tests/unit/views/base/__snapshots__/Collapses.spec.js.snap create mode 100644 tests/unit/views/base/__snapshots__/Forms.spec.js.snap create mode 100644 tests/unit/views/base/__snapshots__/Jumbotrons.spec.js.snap create mode 100644 tests/unit/views/base/__snapshots__/ListGroups.spec.js.snap create mode 100644 tests/unit/views/base/__snapshots__/Navbars.spec.js.snap create mode 100644 tests/unit/views/base/__snapshots__/Navs.spec.js.snap create mode 100644 tests/unit/views/base/__snapshots__/Paginations.spec.js.snap create mode 100644 tests/unit/views/base/__snapshots__/Popovers.spec.js.snap create mode 100644 tests/unit/views/base/__snapshots__/ProgressBars.spec.js.snap create mode 100644 tests/unit/views/base/__snapshots__/Switches.spec.js.snap create mode 100644 tests/unit/views/base/__snapshots__/Table.spec.js.snap create mode 100644 tests/unit/views/base/__snapshots__/Tables.spec.js.snap create mode 100644 tests/unit/views/base/__snapshots__/Tabs.spec.js.snap create mode 100644 tests/unit/views/base/__snapshots__/Tooltips.spec.js.snap rename tests/unit/{ => views/buttons}/BrandButtons.spec.js (85%) rename tests/unit/{ => views/buttons}/ButtonDropdowns.spec.js (85%) rename tests/unit/{ => views/buttons}/ButtonGroups.spec.js (85%) rename tests/unit/{ => views/buttons}/StandardButtons.spec.js (89%) create mode 100644 tests/unit/views/buttons/__snapshots__/BrandButtons.spec.js.snap create mode 100644 tests/unit/views/buttons/__snapshots__/ButtonDropdowns.spec.js.snap create mode 100644 tests/unit/views/buttons/__snapshots__/ButtonGroups.spec.js.snap create mode 100644 tests/unit/views/buttons/__snapshots__/StandardButtons.spec.js.snap rename tests/unit/{ => views/icons}/CoreUIIcons.spec.js (85%) rename tests/unit/{ => views/icons}/Flags.spec.js (84%) rename tests/unit/{ => views/icons}/FontAwesome.spec.js (84%) rename tests/unit/{ => views/icons}/SimpleLineIcons.spec.js (85%) create mode 100644 tests/unit/views/icons/__snapshots__/CoreUIIcons.spec.js.snap create mode 100644 tests/unit/views/icons/__snapshots__/Flags.spec.js.snap create mode 100644 tests/unit/views/icons/__snapshots__/FontAwesome.spec.js.snap create mode 100644 tests/unit/views/icons/__snapshots__/SimpleLineIcons.spec.js.snap rename tests/unit/{ => views/notifications}/Alerts.spec.js (70%) rename tests/unit/{ => views/notifications}/Badges.spec.js (85%) rename tests/unit/{ => views/notifications}/Modals.spec.js (88%) create mode 100644 tests/unit/views/notifications/__snapshots__/Alerts.spec.js.snap create mode 100644 tests/unit/views/notifications/__snapshots__/Badges.spec.js.snap create mode 100644 tests/unit/views/notifications/__snapshots__/Modals.spec.js.snap rename tests/unit/{ => views/pages}/Login.spec.js (83%) rename tests/unit/{ => views/pages}/Page404.spec.js (84%) rename tests/unit/{ => views/pages}/Page500.spec.js (84%) rename tests/unit/{ => views/pages}/Register.spec.js (84%) create mode 100644 tests/unit/views/pages/__snapshots__/Login.spec.js.snap create mode 100644 tests/unit/views/pages/__snapshots__/Page404.spec.js.snap create mode 100644 tests/unit/views/pages/__snapshots__/Page500.spec.js.snap create mode 100644 tests/unit/views/pages/__snapshots__/Register.spec.js.snap rename tests/unit/{ => views/theme}/Colors.spec.js (85%) rename tests/unit/{ => views/theme}/Typography.spec.js (84%) create mode 100644 tests/unit/views/theme/__snapshots__/Colors.spec.js.snap create mode 100644 tests/unit/views/theme/__snapshots__/Typography.spec.js.snap rename tests/unit/{ => views/users}/User.spec.js (76%) create mode 100644 tests/unit/views/users/Users.spec.js create mode 100644 tests/unit/views/users/__snapshots__/User.spec.js.snap create mode 100644 tests/unit/views/users/__snapshots__/Users.spec.js.snap diff --git a/tests/unit/Users.spec.js b/tests/unit/Users.spec.js deleted file mode 100644 index 9f7421be..00000000 --- a/tests/unit/Users.spec.js +++ /dev/null @@ -1,35 +0,0 @@ -import Vue from 'vue' -import { shallowMount, mount } from '@vue/test-utils' -import BootstrapVue from 'bootstrap-vue' -import Users from '@/views/users/Users' - -Vue.use(BootstrapVue) - -describe('Users.vue', () => { - it('has a name', () => { - expect(Users.name).toMatch('Users') - }) - it('has a created hook', () => { - expect(typeof Users.data).toMatch('function') - }) - it('sets the correct default data', () => { - expect(typeof Users.data).toMatch('function') - const defaultData = Users.data() - expect(defaultData.currentPage).toBe(1) - }) - it('is Vue instance', () => { - const wrapper = shallowMount(Users) - expect(wrapper.isVueInstance()).toBe(true) - }) - it('is Users', () => { - const wrapper = shallowMount(Users) - expect(wrapper.is(Users)).toBe(true) - }) - it('renders props.caption when passed', () => { - const caption = 'Users List' - const wrapper = mount(Users, { - propsData: { caption } - }) - expect(wrapper.find('div.card-header > div').text()).toMatch(caption) - }) -}) diff --git a/tests/unit/DefaultAside.spec.js b/tests/unit/containers/DefaultAside.spec.js similarity index 59% rename from tests/unit/DefaultAside.spec.js rename to tests/unit/containers/DefaultAside.spec.js index 52f58b11..b403d47a 100644 --- a/tests/unit/DefaultAside.spec.js +++ b/tests/unit/containers/DefaultAside.spec.js @@ -1,4 +1,5 @@ import Vue from 'vue' +import { shallowMount } from '@vue/test-utils'; import BootstrapVue from 'bootstrap-vue' import DefaultAside from '@/containers/DefaultAside' @@ -8,4 +9,8 @@ describe('DefaultAside.vue', () => { it('has a name', () => { expect(DefaultAside.name).toMatch('DefaultAside') }) + test('renders correctly', () => { + const wrapper = shallowMount(DefaultAside) + expect(wrapper.element).toMatchSnapshot() + }) }) diff --git a/tests/unit/DefaultContainer.spec.js b/tests/unit/containers/DefaultContainer.spec.js similarity index 72% rename from tests/unit/DefaultContainer.spec.js rename to tests/unit/containers/DefaultContainer.spec.js index 5ebbcc1e..556c7804 100644 --- a/tests/unit/DefaultContainer.spec.js +++ b/tests/unit/containers/DefaultContainer.spec.js @@ -1,5 +1,5 @@ import BootstrapVue from 'bootstrap-vue' -import { shallowMount, createLocalVue } from '@vue/test-utils' +import { shallowMount, createLocalVue } from '@vue/test-utils'; import VueRouter from 'vue-router' import DefaultContainer from '@/containers/DefaultContainer' @@ -11,11 +11,18 @@ localVue.use(BootstrapVue) describe('DefaultContainer.vue', () => { it('has a name', () => { - expect(DefaultContainer.name).toMatch('full') + expect(DefaultContainer.name).toMatch('DefaultContainer') }) it('has a created hook', () => { expect(typeof DefaultContainer.data).toMatch('function') }) + test('renders correctly', () => { + const wrapper = shallowMount(DefaultContainer, { + localVue, + router + }) + expect(wrapper.element).toMatchSnapshot() + }) it('sets the correct default data', () => { expect(typeof DefaultContainer.data).toMatch('function') const defaultData = DefaultContainer.data() diff --git a/tests/unit/DefaultHeaderDropdownAccnt.spec.js b/tests/unit/containers/DefaultHeaderDropdownAccnt.spec.js similarity index 77% rename from tests/unit/DefaultHeaderDropdownAccnt.spec.js rename to tests/unit/containers/DefaultHeaderDropdownAccnt.spec.js index 647713fd..cc8e5ff4 100644 --- a/tests/unit/DefaultHeaderDropdownAccnt.spec.js +++ b/tests/unit/containers/DefaultHeaderDropdownAccnt.spec.js @@ -1,6 +1,7 @@ import Vue from 'vue' import BootstrapVue from 'bootstrap-vue' import DefaultHeaderDropdownAccnt from '@/containers/DefaultHeaderDropdownAccnt' +import { shallowMount } from '@vue/test-utils'; Vue.use(BootstrapVue) @@ -16,4 +17,8 @@ describe('DefaultHeaderDropdownAccnt.vue', () => { const defaultData = DefaultHeaderDropdownAccnt.data() expect(defaultData.itemsCount).toBe(42) }) + test('renders correctly', () => { + const wrapper = shallowMount(DefaultHeaderDropdownAccnt) + expect(wrapper.element).toMatchSnapshot() + }) }) diff --git a/tests/unit/containers/__snapshots__/DefaultAside.spec.js.snap b/tests/unit/containers/__snapshots__/DefaultAside.spec.js.snap new file mode 100644 index 00000000..d0f38a0f --- /dev/null +++ b/tests/unit/containers/__snapshots__/DefaultAside.spec.js.snap @@ -0,0 +1,946 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DefaultAside.vue renders correctly 1`] = ` + + + + + + + + Today + + + + +
+ admin@bootstrapmaster.com +
+ +
+ Meeting with + + + Lucas + +
+ + + +   1 - 3pm + + + + + +   Palo Alto, CA + + +
+ + +
+ admin@bootstrapmaster.com +
+ +
+ Skype with + + Megan + +
+ + + +   4 - 5pm + + + + +   On-line + +
+ +
+ + + + Tomorrow + + + + +
+ New UI Project - + + deadline + +
+ + + +   10 - 11pm + + + + +   creativeLabs HQ + + +
+
+ admin@bootstrapmaster.com +
+ +
+ admin@bootstrapmaster.com +
+ +
+ admin@bootstrapmaster.com +
+ +
+ admin@bootstrapmaster.com +
+ +
+ admin@bootstrapmaster.com +
+
+
+ + +
+ + #10 Startups.Garden + + Meetup +
+ + + +   1 - 3pm + + + + +   Palo Alto, CA + +
+ + +
+ + Team meeting + +
+ + + +   4 - 6pm + + + + +   creativeLabs HQ + + +
+
+ admin@bootstrapmaster.com +
+ +
+ admin@bootstrapmaster.com +
+ +
+ admin@bootstrapmaster.com +
+ +
+ admin@bootstrapmaster.com +
+ +
+ admin@bootstrapmaster.com +
+ +
+ admin@bootstrapmaster.com +
+ +
+ admin@bootstrapmaster.com +
+
+
+
+
+ + + + +
+
+
+
+ admin@bootstrapmaster.com + + +
+
+ +
+ + Lukasz Holeczek + + + + 1:52 PM + +
+ +
+ Lorem ipsum dolor sit amet +
+ + + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt... + +
+ +
+ +
+
+
+ admin@bootstrapmaster.com + + +
+
+ +
+ + Lukasz Holeczek + + + + 1:52 PM + +
+ +
+ Lorem ipsum dolor sit amet +
+ + + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt... + +
+ +
+ +
+
+
+ admin@bootstrapmaster.com + + +
+
+ +
+ + Lukasz Holeczek + + + + 1:52 PM + +
+ +
+ Lorem ipsum dolor sit amet +
+ + + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt... + +
+ +
+ +
+
+
+ admin@bootstrapmaster.com + + +
+
+ +
+ + Lukasz Holeczek + + + + 1:52 PM + +
+ +
+ Lorem ipsum dolor sit amet +
+ + + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt... + +
+ +
+ +
+
+
+ admin@bootstrapmaster.com + + +
+
+ +
+ + Lukasz Holeczek + + + + 1:52 PM + +
+ +
+ Lorem ipsum dolor sit amet +
+ + + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt... + +
+
+
+ + + + +
+
+ Settings +
+ +
+
+ + + Option 1 + + + + +
+ +
+ + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + +
+
+ +
+
+ + + Option 2 + + + + +
+ +
+ + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + +
+
+ +
+
+ + + Option 3 + + + + +
+ +
+ + Disabled option. + +
+
+ +
+
+ + + Option 4 + + + + +
+
+ +
+ +
+ System Utilization +
+ +
+ + + CPU Usage + + +
+ + + + + 348 Processes. 1/4 Cores. + + +
+ + + Memory Usage + + +
+ + + + + 11444GB/16384MB + + +
+ + + SSD 1 Usage + + +
+ + + + + 243GB/256GB + + +
+ + + SSD 2 Usage + + +
+ + + + + 25GB/256GB + +
+
+
+`; diff --git a/tests/unit/containers/__snapshots__/DefaultContainer.spec.js.snap b/tests/unit/containers/__snapshots__/DefaultContainer.spec.js.snap new file mode 100644 index 00000000..929bd638 --- /dev/null +++ b/tests/unit/containers/__snapshots__/DefaultContainer.spec.js.snap @@ -0,0 +1,231 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DefaultContainer.vue renders correctly 1`] = ` +
+ + + + + CoreUI Logo + + CoreUI Logo + + + + + + + Dashboard + + + + Users + + + + Settings + + + + + + + + + 5 + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + +
+ + +
+ +
+
+ + + + +
+ + +
+ + CoreUI + + + + © 2018 creativeLabs. + +
+ +
+ + Powered by + + + + CoreUI for Vue + +
+
+
+`; diff --git a/tests/unit/containers/__snapshots__/DefaultHeaderDropdownAccnt.spec.js.snap b/tests/unit/containers/__snapshots__/DefaultHeaderDropdownAccnt.spec.js.snap new file mode 100644 index 00000000..7033a750 --- /dev/null +++ b/tests/unit/containers/__snapshots__/DefaultHeaderDropdownAccnt.spec.js.snap @@ -0,0 +1,243 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DefaultHeaderDropdownAccnt.vue renders correctly 1`] = ` + + + \\ + + + +`; diff --git a/tests/unit/shared/classes.spec.js b/tests/unit/shared/classes.spec.js new file mode 100644 index 00000000..d20e55bd --- /dev/null +++ b/tests/unit/shared/classes.spec.js @@ -0,0 +1,33 @@ +import {sidebarCssClasses, asideMenuCssClasses, validBreakpoints, checkBreakpoint} from '@/shared/classes' + +test('sidebarCssClasses', () => { + expect(sidebarCssClasses.constructor === Array).toBe(true); + expect(sidebarCssClasses.length).toBe(5); + expect(sidebarCssClasses).toContain('sidebar-show'); + expect(sidebarCssClasses).toContain('sidebar-sm-show'); + expect(sidebarCssClasses).toContain('sidebar-md-show'); + expect(sidebarCssClasses).toContain('sidebar-lg-show'); + expect(sidebarCssClasses).toContain('sidebar-xl-show'); +}); +test('asideMenuCssClasses', () => { + expect(asideMenuCssClasses.constructor === Array).toBe(true); + expect(asideMenuCssClasses.length).toBe(5); + expect(asideMenuCssClasses).toContain('aside-menu-show'); + expect(asideMenuCssClasses).toContain('aside-menu-sm-show'); + expect(asideMenuCssClasses).toContain('aside-menu-md-show'); + expect(asideMenuCssClasses).toContain('aside-menu-lg-show'); + expect(asideMenuCssClasses).toContain('aside-menu-xl-show'); +}); +test('validBreakpoints', () => { + expect(validBreakpoints.constructor === Array).toBe(true); + expect(validBreakpoints.length).toBe(4); + expect(validBreakpoints).toContain('sm'); + expect(validBreakpoints).toContain('md'); + expect(validBreakpoints).toContain('lg'); + expect(validBreakpoints).toContain('xl'); +}); +test('checkBreakpoint', () => { + expect(checkBreakpoint.constructor === Function).toBe(true); + expect(checkBreakpoint('sm', validBreakpoints)).toBe(true); + expect(checkBreakpoint('xs', validBreakpoints)).toBe(false); +}); diff --git a/tests/unit/shared/toggle-classes.spec.js b/tests/unit/shared/toggle-classes.spec.js new file mode 100644 index 00000000..8412233a --- /dev/null +++ b/tests/unit/shared/toggle-classes.spec.js @@ -0,0 +1,22 @@ +import { sidebarCssClasses } from '@/shared/classes' +import toggleClasses from '@/shared/toggle-classes' + +test('toggleClasses', () => { + const cssClass = `sidebar-show` + expect(toggleClasses.constructor === Function).toBe(true) + toggleClasses(cssClass, sidebarCssClasses ) + console.log(document.body.classList) + expect(document.body.classList).toMatchObject({ '0': 'sidebar-show' }) + toggleClasses("sidebar-xl-show", sidebarCssClasses ) + console.log(document.body.classList) + toggleClasses("sidebar-lg-show", sidebarCssClasses ) + console.log(document.body.classList) + toggleClasses("sidebar-md-show", sidebarCssClasses ) + expect(document.body.classList).toMatchObject({ '0': 'sidebar-xl-show', '1': 'sidebar-lg-show', '2': 'sidebar-md-show' }) + console.log(document.body.classList) + toggleClasses("sidebar-xl-show", sidebarCssClasses ) + console.log(document.body.classList) + toggleClasses(cssClass, sidebarCssClasses ) + expect(document.body.classList).toMatchObject({ '0': 'sidebar-show' }) + console.log(document.body.classList) +}); diff --git a/tests/unit/shared/utils.spec.js b/tests/unit/shared/utils.spec.js new file mode 100644 index 00000000..5c40d760 --- /dev/null +++ b/tests/unit/shared/utils.spec.js @@ -0,0 +1,23 @@ +import { random, shuffleArray } from '@/shared/utils' + +test('random', () => { + expect(random.constructor === Function).toBe(true) + expect(random(10,10)).toBe(10); + let nRandom = random(50,200) + expect(nRandom).toBeGreaterThanOrEqual(50) + expect(nRandom).toBeLessThanOrEqual(200) + nRandom = random(80,100) + expect(nRandom).toBeGreaterThanOrEqual(80) + expect(nRandom).toBeLessThanOrEqual(100) + nRandom = random(100,101) + expect(nRandom).toBeGreaterThanOrEqual(100) + expect(nRandom).toBeLessThanOrEqual(101) +}); + +test('shuffleArray', () => { + expect(shuffleArray.constructor === Function).toBe(true) + let testArray = [1,2,3] + expect(shuffleArray(testArray).constructor === Array).toBe(true) + testArray = [{a:1},{a:2},{a:3}] + expect(shuffleArray(testArray).constructor === Array).toBe(true) +}) diff --git a/tests/unit/Charts.spec.js b/tests/unit/views/Charts.spec.js similarity index 72% rename from tests/unit/Charts.spec.js rename to tests/unit/views/Charts.spec.js index 33d63cf9..adce817b 100644 --- a/tests/unit/Charts.spec.js +++ b/tests/unit/views/Charts.spec.js @@ -1,5 +1,5 @@ import Vue from 'vue' -import { shallowMount } from '@vue/test-utils' +import { shallowMount } from '@vue/test-utils'; import BootstrapVue from 'bootstrap-vue' import Charts from '@/views/Charts' @@ -17,4 +17,8 @@ describe('Charts.vue', () => { const wrapper = shallowMount(Charts) expect(wrapper.is(Charts)).toBe(true) }) + test('renders correctly', () => { + const wrapper = shallowMount(Charts) + expect(wrapper.element).toMatchSnapshot() + }) }) diff --git a/tests/unit/Dashboard.spec.js b/tests/unit/views/Dashboard.spec.js similarity index 62% rename from tests/unit/Dashboard.spec.js rename to tests/unit/views/Dashboard.spec.js index a89b7e3f..4c7077a3 100644 --- a/tests/unit/Dashboard.spec.js +++ b/tests/unit/views/Dashboard.spec.js @@ -29,4 +29,17 @@ describe('Dashboard.vue', () => { const wrapper = shallowMount(Dashboard) expect(wrapper.find('#traffic').text()).toMatch('Traffic') }) + test('renders correctly', () => { + const wrapper = shallowMount(Dashboard) + expect(wrapper.element).toMatchSnapshot() + }) + it('should have methods', () => { + expect(typeof Dashboard.methods.variant ).toEqual('function') + expect(Dashboard.methods.variant(25)).toBe('info') + expect(Dashboard.methods.variant(50)).toBe('success') + expect(Dashboard.methods.variant(75)).toBe('warning') + expect(Dashboard.methods.variant(100)).toBe('danger') + expect(typeof Dashboard.methods.flag ).toEqual('function') + expect(Dashboard.methods.flag('us')).toBe('flag-icon flag-icon-us') + }) }) diff --git a/tests/unit/Widgets.spec.js b/tests/unit/views/Widgets.spec.js similarity index 86% rename from tests/unit/Widgets.spec.js rename to tests/unit/views/Widgets.spec.js index 27fe9e32..cd4a62cc 100644 --- a/tests/unit/Widgets.spec.js +++ b/tests/unit/views/Widgets.spec.js @@ -25,4 +25,8 @@ describe('Widgets.vue', () => { const wrapper = shallowMount(Widgets) expect(wrapper.is(Widgets)).toBe(true) }) + test('renders correctly', () => { + const wrapper = shallowMount(Widgets) + expect(wrapper.element).toMatchSnapshot() + }) }) diff --git a/tests/unit/views/__snapshots__/Charts.spec.js.snap b/tests/unit/views/__snapshots__/Charts.spec.js.snap new file mode 100644 index 00000000..7204dbe5 --- /dev/null +++ b/tests/unit/views/__snapshots__/Charts.spec.js.snap @@ -0,0 +1,121 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Charts.vue renders correctly 1`] = ` +
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ +
+
+
+
+`; diff --git a/tests/unit/views/__snapshots__/Dashboard.spec.js.snap b/tests/unit/views/__snapshots__/Dashboard.spec.js.snap new file mode 100644 index 00000000..e479a0ac --- /dev/null +++ b/tests/unit/views/__snapshots__/Dashboard.spec.js.snap @@ -0,0 +1,1657 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Dashboard.vue renders correctly 1`] = ` +
+ + + + + + + + + Action + + + + Another action + + + + Something else here... + + + + Disabled action + + + +

+ 9.823 +

+ +

+ Members online +

+
+ + +
+
+ + + + + + + + + Action + + + + Another action + + + + Something else here... + + + + Disabled action + + + +

+ 9.823 +

+ +

+ Members online +

+
+ + +
+
+ + + + + + + + + Action + + + + Another action + + + + Something else here... + + + + Disabled action + + + +

+ 9.823 +

+ +

+ Members online +

+
+ + +
+
+ + + + + + + + + Action + + + + Another action + + + + Something else here... + + + + Disabled action + + + +

+ 9.823 +

+ +

+ Members online +

+
+ + +
+
+
+ + + + +

+ Traffic +

+ +
+ November 2017 +
+
+ + + + + + + + + + Day + + + + Month + + + + Year + + + + +
+ + + +
+ + +
+ Visits +
+ + + 29.703 Users (40%) + + + +
+ + +
+ Unique +
+ + + 24.093 Users (20%) + + + +
+ + +
+ Pageviews +
+ + + 78.706 Views (60%) + + + +
+ + +
+ New Users +
+ + + 22.123 Users (80%) + + + +
+ + +
+ Bounce Rate +
+ + + Average Rate (40.15%) + + + +
+
+
+
+ + + +
+
+ + +
+ +
+
+ +
+
+
+ 89k +
+ +
+ friends +
+
+ +
+
+ 459 +
+ +
+ feeds +
+
+
+
+
+ + +
+
+ + +
+ +
+
+ +
+
+
+ 973k +
+ +
+ followers +
+
+ +
+
+ 1.792 +
+ +
+ tweets +
+
+
+
+
+ + +
+
+ + +
+ +
+
+ +
+
+
+ 500+ +
+ +
+ contacts +
+
+ +
+
+ 292 +
+ +
+ feeds +
+
+
+
+
+ + +
+
+ + +
+ +
+
+ +
+
+
+ 894 +
+ +
+ followers +
+
+ +
+
+ 92 +
+ +
+ circles +
+
+
+
+
+
+ + + + + + + + + + + New Clients + +
+ + + 9,123 + + +
+ +
+
+
+ + + + + Recurring Clients + +
+ + + 22,643 + + +
+ +
+
+
+
+ +
+ +
+
+ + + Monday + + +
+ +
+ + + +
+
+ +
+
+ + + Tuesday + + +
+ +
+ + + +
+
+ +
+
+ + + Wednesday + + +
+ +
+ + + +
+
+ +
+
+ + + Thursday + + +
+ +
+ + + +
+
+ +
+
+ + + Friday + + +
+ +
+ + + +
+
+ +
+
+ + + Saturday + + +
+ +
+ + + +
+
+ +
+
+ + + Sunday + + +
+ +
+ + + +
+
+ +
+ + + +   + + + + New clients +    + + + +   + + + + Recurring clients + + +
+
+ + + + + + + Pageviews + +
+ + + 78,623 + + +
+ +
+
+
+ + + + + Organic + +
+ + + 49,123 + + +
+ +
+
+
+
+ +
+ +
    +
    +
    + + + + Male + + + + 43% + +
    + +
    + +
    +
    + +
    +
    + + + + Female + + + + 37% + +
    + +
    + +
    +
    + +
    +
    + + + + Organic Search + + + + 191,235 + + (56%) + + +
    + +
    + +
    +
    + +
    +
    +