Skip to content

Commit

Permalink
store structure and testing mocha tdd setup
Browse files Browse the repository at this point in the history
  • Loading branch information
kswope committed Jul 8, 2017
1 parent 699ab24 commit d0ac9cf
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 14 deletions.
4 changes: 3 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ module.exports = {
'generator-star-spacing': 0,
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
"quotes": 0
"quotes": 0,
"space-in-parens": 0,
"space-before-function-paren": 0
}
}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"dependencies": {
"milligram": "^1.3.0",
"vue": "^2.3.3",
"vue-router": "^2.3.1"
"vue-router": "^2.3.1",
"vuex": "^2.3.1"
},
"devDependencies": {
"autoprefixer": "^6.7.2",
Expand All @@ -28,7 +29,7 @@
"babel-preset-env": "^1.3.2",
"babel-preset-stage-2": "^6.22.0",
"babel-register": "^6.22.0",
"chai": "^3.5.0",
"chai": "^4.0.2",
"chalk": "^1.1.3",
"chromedriver": "^2.27.2",
"connect-history-api-fallback": "^1.3.0",
Expand Down
2 changes: 2 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import Vue from 'vue'
import App from './App'
import router from './router'
import store from "./store"

import "milligram/dist/milligram.css"

Expand All @@ -12,6 +13,7 @@ Vue.config.productionTip = false
new Vue({
el: '#app',
router,
store,
template: '<App/>',
components: { App }
})
13 changes: 13 additions & 0 deletions src/store/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

import Vue from "vue"
import Vuex from "vuex"

import persons from "./persons"

Vue.use(Vuex)

const store = new Vuex.Store({
modules: { persons }
})

export default store
9 changes: 9 additions & 0 deletions src/store/persons/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

export const state = {}

export default {
state,
getters: { a: "getter" },
actions: {},
mutations: {}
}
6 changes: 6 additions & 0 deletions test/unit/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import Vue from 'vue'

// can't run unit tests without this
// PhantomJS 2.1.1 (Linux 0.0.0) ERROR
// Error: [vuex] vuex requires a Promise polyfill in this browser.
// at webpack:///~/vuex/dist/vuex.esm.js:96:0 <- index.js:13554
import "es6-promise/auto"

Vue.config.productionTip = false

// require all test files (files that ends with .spec.js)
Expand Down
1 change: 1 addition & 0 deletions test/unit/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = function (config) {
// 2. add it to the `browsers` array below.
browsers: ['PhantomJS'],
frameworks: ['mocha', 'sinon-chai', 'phantomjs-shim'],
client: { mocha: { ui: "tdd" } },
reporters: ['spec', 'coverage'],
files: ['./index.js'],
preprocessors: {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/specs/Hello.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Vue from 'vue'
import Hello from '@/components/Hello'

describe('Hello.vue', () => {
it('should render correct contents', () => {
suite('Hello.vue', () => {
test('should render correct contents', () => {
const Constructor = Vue.extend(Hello)
const vm = new Constructor().$mount()
expect(vm.$el.querySelector('.hello h1').textContent)
Expand Down
Empty file.
14 changes: 14 additions & 0 deletions test/unit/specs/store/persons/getters.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

import persons, { state } from "@/store/persons"
const { getters } = persons
import { assert } from "chai"

console.log(state)
console.log(getters)

suite( "something", () => {
test( "the test", () => {
console.log( assert )
} )
} )

Empty file.
43 changes: 34 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1129,13 +1129,16 @@ chai-nightwatch@~0.1.x:
assertion-error "1.0.0"
deep-eql "0.1.3"

chai@^3.5.0:
version "3.5.0"
resolved "https://registry.yarnpkg.com/chai/-/chai-3.5.0.tgz#4d02637b067fe958bdbfdd3a40ec56fef7373247"
chai@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/chai/-/chai-4.0.2.tgz#2f7327c4de6f385dd7787999e2ab02697a32b83b"
dependencies:
assertion-error "^1.0.1"
deep-eql "^0.1.3"
type-detect "^1.0.0"
check-error "^1.0.1"
deep-eql "^2.0.1"
get-func-name "^2.0.0"
pathval "^1.0.0"
type-detect "^4.0.0"

chalk@^1.0.0, chalk@^1.1.0, chalk@^1.1.1, chalk@^1.1.3:
version "1.1.3"
Expand All @@ -1155,6 +1158,10 @@ chalk@^2.0.1:
escape-string-regexp "^1.0.5"
supports-color "^4.0.0"

check-error@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82"

chokidar@^1.4.1, chokidar@^1.4.3:
version "1.7.0"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468"
Expand Down Expand Up @@ -1686,12 +1693,18 @@ decamelize@^1.0.0, decamelize@^1.1.1, decamelize@^1.1.2:
version "1.2.0"
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"

deep-eql@0.1.3, deep-eql@^0.1.3:
deep-eql@0.1.3:
version "0.1.3"
resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-0.1.3.tgz#ef558acab8de25206cd713906d74e56930eb69f2"
dependencies:
type-detect "0.1.1"

deep-eql@^2.0.1:
version "2.0.2"
resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-2.0.2.tgz#b1bac06e56f0a76777686d50c9feb75c2ed7679a"
dependencies:
type-detect "^3.0.0"

deep-extend@~0.4.0:
version "0.4.2"
resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.2.tgz#48b699c27e334bf89f10892be432f6e4c7d34a7f"
Expand Down Expand Up @@ -2552,6 +2565,10 @@ get-caller-file@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.2.tgz#f702e63127e7e231c160a80c1554acb70d5047e5"

get-func-name@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41"

get-stdin@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe"
Expand Down Expand Up @@ -4314,6 +4331,10 @@ path-type@^1.0.0:
pify "^2.0.0"
pinkie-promise "^2.0.0"

pathval@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.0.tgz#b942e6d4bde653005ef6b71361def8727d0645e0"

pbkdf2@^3.0.3:
version "3.0.12"
resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.0.12.tgz#be36785c5067ea48d806ff923288c5f750b6b8a2"
Expand Down Expand Up @@ -5671,9 +5692,9 @@ type-detect@0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-0.1.1.tgz#0ba5ec2a885640e470ea4e8505971900dac58822"

type-detect@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-1.0.0.tgz#762217cc06db258ec48908a1298e8b95121e8ea2"
type-detect@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-3.0.0.tgz#46d0cc8553abb7b13a352b0d6dea2fd58f2d9b55"

type-detect@^4.0.0:
version "4.0.3"
Expand Down Expand Up @@ -5880,6 +5901,10 @@ vue@^2.3.3:
version "2.3.4"
resolved "https://registry.yarnpkg.com/vue/-/vue-2.3.4.tgz#5ec3b87a191da8090bbef56b7cfabd4158038171"

vuex@^2.3.1:
version "2.3.1"
resolved "https://registry.yarnpkg.com/vuex/-/vuex-2.3.1.tgz#cde8e997c1f9957719bc7dea154f9aa691d981a6"

watchpack@^1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-1.3.1.tgz#7d8693907b28ce6013e7f3610aa2a1acf07dad87"
Expand Down

0 comments on commit d0ac9cf

Please sign in to comment.