Skip to content

Commit

Permalink
refactor: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dennishendriksen committed Jun 11, 2020
1 parent 97f9ab2 commit 518917c
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ npm-debug.log
/.idea/

# misc
package-lock.json
package-lock.json
/coverage/
4 changes: 4 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
preset: '@vue/cli-plugin-unit-jest/presets/typescript-and-babel',
collectCoverage: true
}
17 changes: 16 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"test:unit": "vue-cli-service test:unit",
"lint": "vue-cli-service lint",
"i18n:report": "vue-cli-service i18n:report --src './src/**/*.?(js|vue)' --locales './src/locales/**/*.json'"
},
Expand All @@ -22,15 +23,18 @@
},
"devDependencies": {
"@babel/polyfill": "^7.10.1",
"@types/jest": "^24.0.19",
"@typescript-eslint/eslint-plugin": "^2.26.0",
"@typescript-eslint/parser": "^2.26.0",
"@vue/cli-plugin-babel": "~4.3.0",
"@vue/cli-plugin-eslint": "~4.3.0",
"@vue/cli-plugin-router": "^4.4.1",
"@vue/cli-plugin-typescript": "^4.4.1",
"@vue/cli-plugin-unit-jest": "^4.4.1",
"@vue/cli-plugin-vuex": "^4.4.1",
"@vue/cli-service": "~4.3.0",
"@vue/eslint-config-typescript": "^5.0.2",
"@vue/test-utils": "^1.0.3",
"babel-eslint": "^10.1.0",
"bootstrap": "^4.3.1",
"eslint": "^6.7.2",
Expand Down Expand Up @@ -59,7 +63,18 @@
"parserOptions": {
"parser": "@typescript-eslint/parser"
},
"rules": {}
"rules": {},
"overrides": [
{
"files": [
"**/__tests__/*.{j,t}s?(x)",
"**/tests/unit/**/*.spec.{j,t}s?(x)"
],
"env": {
"jest": true
}
}
]
},
"browserslist": [
"> 1%",
Expand Down
38 changes: 38 additions & 0 deletions tests/unit/store/mutations.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import initialState from '@/store/state'
import mutations from '@/store/mutations'
import {State} from "@/types/State";

test('set metadata', () => {
const testState: State = { ...initialState }
const metadata = {}
mutations.setMetadata(testState, metadata)
expect(testState.metadata).toBe(metadata)
})

test('set samples', () => {
const testState: State = { ...initialState }
const samples = {}
mutations.setSamples(testState, samples)
expect(testState.samples).toBe(samples)
})

test('set selected sample', () => {
const testState: State = { ...initialState }
const sample = {}
mutations.setSelectedSample(testState, sample)
expect(testState.selectedSample).toBe(sample)
})

test('set selected sample phenotypes', () => {
const testState: State = { ...initialState }
const phenotypes = {}
mutations.setSelectedSamplePhenotypes(testState, phenotypes)
expect(testState.selectedSamplePhenotypes).toBe(phenotypes)
})

test('set records', () => {
const testState: State = { ...initialState }
const records = {}
mutations.setRecords(testState, records)
expect(testState.records).toBe(records)
})
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"types": [
"webpack-env",
"webpack",
"webpack-env"
"webpack-env",
"jest"
],
"paths": {
"@/*": [
Expand Down

0 comments on commit 518917c

Please sign in to comment.