Skip to content

Commit

Permalink
Fix Vue Test Utils Warnings [Ticket: NCI-9]
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmstokes committed Jul 14, 2021
1 parent 453bbba commit 51e59dd
Show file tree
Hide file tree
Showing 33 changed files with 47 additions and 53 deletions.
10 changes: 1 addition & 9 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,5 @@
]
]
}
},
"plugins": [
[
"@babel/plugin-proposal-private-property-in-object",
{
"loose": true
}
]
]
}
}
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
presets: ['@babel/preset-env'],
"plugins": [
plugins: [
[
"@babel/plugin-proposal-private-property-in-object",
{
Expand Down
5 changes: 3 additions & 2 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ export default {
],
collectCoverage: true,
collectCoverageFrom: [
'<rootDir>/nci/components/**/*.{js,vue,ts}',
'<rootDir>/nci/app/components/**/*.{js,vue,ts}',
'<rootDir>/nci/storybook/**/*.{js,vue,ts}',
'<rootDir>/nci/app/factories/**/*.{js,vue,ts}',
'<rootDir>/pages/**/*.{js,vue,ts}',
'<rootDir>/store/**/*.{js,vue,ts}',
"!**/node_modules/**"
],
testEnvironment: "jsdom"
testEnvironment: "jsdom",
setupFilesAfterEnv: ['./nci/app/testing/registerComponents.ts']
}
3 changes: 1 addition & 2 deletions nci.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import Theme from "./nci/theme/default-light";
/** Import App Config Type */
import { AppConfig } from '@/nci/app/interfaces'

const nciConfig = {
export const nciConfig = {
config: Config,
theme: Theme,
} as AppConfig;

export default nciConfig;
2 changes: 1 addition & 1 deletion nci/app/appConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import nciConfig from "../../nci.config"
import { nciConfig } from "../../nci.config"

/** Import App Config Type */
import { AppConfig } from '@/nci/app/interfaces'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { mount } from '@vue/test-utils'
import nciAnchor from '@/nci/components/nci-anchor/index.vue'
import nciAnchor from '@/nci/app/components/nci-anchor/index.vue'
import { Button } from '@/nci/app/interfaces';

/** Button Component Tests */
Expand All @@ -22,7 +22,6 @@ describe('nci-anchor component', () => {
} as Button,
stubs: ['nuxt-link']
})

/** Check the component mounted */
expect(wrapper.vm).toBeTruthy();

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

import { mount } from '@vue/test-utils';

import nciAnchor from '@/nci/components/nci-anchor/index.vue';
import nciAnchor from '@/nci/app/components/nci-anchor/index.vue';

//👇 Imports a specific story for the test
import { button } from '@/nci/components/nci-anchor/stories/button/index.stories';
import { button } from '@/nci/app/components/nci-anchor/stories/button/index.stories';

it('renders the button in the primary state', () => {
const wrapper = mount(nciAnchor, {
propsData: button.args,
stubs: ['nuxt-link']
});

expect(wrapper).toBeTruthy();
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** Import the Nuxt Image component */
import nciAnchor from '@/nci/components/nci-anchor/index.vue';
import nciAnchor from '@/nci/app/components/nci-anchor/index.vue';

/** Import shared Typeface interfaces */
import { Button } from '@/nci/app/interfaces';
Expand Down Expand Up @@ -47,5 +47,4 @@ const datab = {
export const button: Story<Button> = Templateb.bind({})
button.args = injectObject(Theme.anchor, datab)
button.decorators = [() => ({ template: '<div class="mt-10"><story /></div>' })];
//console.log(injectObject(Theme.anchor, datab))
export { Sizes } from '@/nci/components/nci-anchor/stories/list/index.stories'
export { Sizes } from '@/nci/app/components/nci-anchor/stories/list/index.stories'
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import { mount } from '@vue/test-utils';

import { Sizes } from '@/nci/components/nci-anchor/stories/list/index.stories';
import nciAnchor from '@/nci/components/nci-anchor/index.vue';
import { Sizes } from '@/nci/app/components/nci-anchor/stories/list/index.stories';
import nciAnchor from '@/nci/app/components/nci-anchor/index.vue';
import { Button } from '@/nci/app/interfaces'

//👇 Imports a specific story for the test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** Import the Nuxt Image component */
import nciAnchor from '@/nci/components/nci-anchor/index.vue';
import nciAnchor from '@/nci/app/components/nci-anchor/index.vue';

/** Import shared Typeface interfaces */
import { Button } from '@/nci/app/interfaces';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { mount } from '@vue/test-utils'
import nciImage from '@/nci/components/nci-image/index.vue'
import nciImage from '@/nci/app/components/nci-image/index.vue'
import { Image } from '@/nci/app/interfaces';

describe('nci-image component', () => {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { mount } from '@vue/test-utils'
import nciImage from '@/nci/components/nci-image/index.vue'
import nciImage from '@/nci/app/components/nci-image/index.vue'

import { image } from '@/nci/components/nci-image/stories/image/index.stories';
import { image } from '@/nci/app/components/nci-image/stories/image/index.stories';

/** Img Component Tests */
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** Import the Nuxt Image component */
import nciImage from '@/nci/components/nci-image/index.vue';
import nciImage from '@/nci/app/components/nci-image/index.vue';

/** Import shared Typeface interfaces */
import { Image } from '@/nci/app/interfaces';
Expand Down Expand Up @@ -44,4 +44,4 @@ export const image: Story<Image> = Templateb.bind({});
image.args = data


export { Sizes } from '@/nci/components/nci-image/stories/list/index.stories'
export { Sizes } from '@/nci/app/components/nci-image/stories/list/index.stories'
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import { mount } from '@vue/test-utils';

import { Sizes } from '@/nci/components/nci-image/stories/list/index.stories';
import nciImage from '@/nci/components/nci-image/index.vue';
import { Sizes } from '@/nci/app/components/nci-image/stories/list/index.stories';
import nciImage from '@/nci/app/components/nci-image/index.vue';
import { Image } from '@/nci/app/interfaces'

// Imports a specific story for the test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** Import the Nuxt Image component */
import nciImage from '@/nci/components/nci-image/index.vue';
import nciImage from '@/nci/app/components/nci-image/index.vue';

/** Import shared Typeface interfaces */
import { Image } from '@/nci/app/interfaces';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { mount } from '@vue/test-utils'
import nciPage from '@/nci/components/nci-page/index.vue';
import nciPage from '@/nci/app/components/nci-page/index.vue';

import { Pages, Page } from '@/nci/app/interfaces';
import Config from '@/nci/data/demo';
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { mount } from '@vue/test-utils'
import nciSection from '@/nci/components/nci-section/index.vue';
import nciSection from '@/nci/app/components/nci-section/index.vue';

import { Pages } from '@/nci/app/interfaces';
import Config from '@/nci/data/demo';
Expand Down Expand Up @@ -32,6 +32,7 @@ describe('nci-section component', () => {
propsData: pageSections[key2],
stubs: ['nuxt-link']
})

/** Check the component mounted */
expect(wrapper.vm).toBeTruthy();
})
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import registerComponents from '@/nci/app/testing/registerComponents'

import { story } from '@/nci/components/nci-section/stories/index.stories'
import { story } from '@/nci/app/components/nci-section/stories/index.stories'

/** Section Component Tests */
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { mount } from '@vue/test-utils'
import nciTitle from '@/nci/components/nci-title/index.vue';
import nciTitle from '@/nci/app/components/nci-title/index.vue';
import { Title } from '@/nci/app/interfaces';

/** Img Component Tests */
Expand Down Expand Up @@ -40,7 +40,6 @@ describe('nci-title component', () => {
/** Check props match */
expect(wrapper.props().value).toBe('My Awesome Website');
expect(wrapper.props().tag).toBe("h1");

/** Check an image exists in the DOM */
expect(wrapper.find('h1').exists()).toBe(true);

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { mount } from '@vue/test-utils'
import nciTitle from '@/nci/components/nci-title/index.vue'
import nciTitle from '@/nci/app/components/nci-title/index.vue'

import { Sizes } from '@/nci/components/nci-title/stories/list/index.stories';
import { Sizes } from '@/nci/app/components/nci-title/stories/list/index.stories';

import { Title } from '@/nci/app/interfaces'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** Import the Nuxt Image component */
import nciTitle from '@/nci/components/nci-title/index.vue';
import nciTitle from '@/nci/app/components/nci-title/index.vue';

/** Import shared Typeface interfaces */
import { Title } from '@/nci/app/interfaces';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { mount } from '@vue/test-utils'
import nciTitle from '@/nci/components/nci-title/index.vue'
import nciTitle from '@/nci/app/components/nci-title/index.vue'

import { title } from '@/nci/components/nci-title/stories/title/index.stories';
import { title } from '@/nci/app/components/nci-title/stories/title/index.stories';

/** Title Component Tests */
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** Import the Nuxt Image component */
import nciTitle from '@/nci/components/nci-title/index.vue';
import nciTitle from '@/nci/app/components/nci-title/index.vue';

/** Import shared Typeface interfaces */
import { Title } from '@/nci/app/interfaces';
Expand Down Expand Up @@ -53,4 +53,4 @@ const blah = injectObject(Theme.title, data)
const result = blah;
title.args = result

export { Sizes } from '@/nci/components/nci-title/stories/list/index.stories'
export { Sizes } from '@/nci/app/components/nci-title/stories/list/index.stories'
8 changes: 8 additions & 0 deletions nci/app/helpers/math/floatToFixed/__test__/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { floatToFixed } from '@/nci/app/helpers/math/floatToFixed';

describe('Set float decimal length', () => {
it('Should return a number with corresponding decimal place length', () => {
const checkNumber = floatToFixed(1.23945847584748, 2)
expect(checkNumber).toBe(1.24)
})
})
2 changes: 1 addition & 1 deletion nci/app/testing/registerComponents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Vue from 'vue';
function registerComponents(): void {

// Automatically register all components
const fileComponents = glob.sync(path.join(__dirname, '../../components/**/index.vue'));
const fileComponents = glob.sync(path.join(__dirname, '../components/**/index.vue'));

// Iterate through components directory and add each file object to an array
for (const file of fileComponents) {
Expand Down
5 changes: 0 additions & 5 deletions nci/test/jest.setup.js

This file was deleted.

4 changes: 2 additions & 2 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ const config: NuxtConfig = {
'@storybook/addon-controls',
'@storybook/addon-notes',
],
stories: ['@/nci/components/**/*/index.stories.@(ts)']
stories: ['@/nci/app/components/**/*/index.stories.@(ts)']
},
tailwindcss: {
cssPath: '@/assets/css/tailwind.css',
configPath: '@/tailwind.config.ts',
},
// Auto import components: https://go.nuxtjs.dev/config-components
components: ['@/nci/components'/*'@/components'*/],
components: ['@/nci/app/components'/*'@/components'*/],

// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
buildModules: [
Expand Down

0 comments on commit 51e59dd

Please sign in to comment.