diff --git a/CHANGELOG.md b/CHANGELOG.md index d8c98fa3..e4154a0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,21 @@ ## [CoreUI for Vue.js](./README.md) version `changelog` +##### `v2.0.2` +- refactor: extract random() to `shared/utils` +- refactor: extract shuffleArray() to shared/utils +- refactor: Tables pass items as props to Table +- refactor: some views minor cleanup +- tests(e2e): add some more test cases +- tests(unit): add some more test cases and snapshots +- chore: update `@coreui/coreui` to `2.0.20` +- chore: update `chart.js` to `2.7.3` +- chore: update `@vue/cli-plugin-babel` to `3.0.5` +- chore: update `@vue/cli-plugin-e2e-nightwatch` to `3.0.5` +- chore: update `@vue/cli-plugin-eslint` to `3.0.5` +- chore: update `@vue/cli-plugin-unit-jest` to `3.0.5` +- chore: update `@vue/cli-service` to `3.0.5` +- chore: update `node-sass` to `4.9.4` + ##### `v2.0.1` - refactor(Modals): add spacing - refactor(BrandButtons): add spacing diff --git a/package.json b/package.json index 3070256a..00b14eaf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@coreui/coreui-free-vue-admin-template", - "version": "2.0.1", + "version": "2.0.2", "description": "Open Source Bootstrap Admin Template", "author": "Łukasz Holeczek", "homepage": "http://coreui.io", @@ -14,13 +14,13 @@ "test:e2e": "vue-cli-service test:e2e" }, "dependencies": { - "@coreui/coreui": "^2.0.14", + "@coreui/coreui": "^2.0.20", "@coreui/coreui-plugin-chartjs-custom-tooltips": "^1.2.0", "@coreui/icons": "0.3.0", "@coreui/vue": "^2.0.2", "bootstrap": "^4.1.3", "bootstrap-vue": "^2.0.0-rc.11", - "chart.js": "^2.7.2", + "chart.js": "^2.7.3", "core-js": "^2.5.7", "css-vars-ponyfill": "^1.11.1", "flag-icon-css": "^3.2.0", @@ -33,17 +33,17 @@ "vue-router": "^3.0.1" }, "devDependencies": { - "@vue/cli-plugin-babel": "^3.0.4", - "@vue/cli-plugin-e2e-nightwatch": "^3.0.4", - "@vue/cli-plugin-eslint": "^3.0.4", - "@vue/cli-plugin-unit-jest": "^3.0.4", - "@vue/cli-service": "^3.0.4", + "@vue/cli-plugin-babel": "^3.0.5", + "@vue/cli-plugin-e2e-nightwatch": "^3.0.5", + "@vue/cli-plugin-eslint": "^3.0.5", + "@vue/cli-plugin-unit-jest": "^3.0.5", + "@vue/cli-service": "^3.0.5", "@vue/test-utils": "^1.0.0-beta.25", "babel-core": "^7.0.0-bridge.0", "babel-jest": "^23.6.0", "growl": "^1.10.5", "https-proxy-agent": "^2.2.1", - "node-sass": "^4.9.3", + "node-sass": "^4.9.4", "sass-loader": "^7.1.0", "vue-template-compiler": "^2.5.17" }, 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/shared/utils.js b/src/shared/utils.js new file mode 100644 index 00000000..80999d08 --- /dev/null +++ b/src/shared/utils.js @@ -0,0 +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/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: [ 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 @@ 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, 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() 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%) + + +
    + +
    + +
    +
    + +
    +
    +