refs #434 Add mocha test and run in circleci
This commit is contained in:
parent
60a8add22e
commit
bce8cf9ce9
4
.babelrc
4
.babelrc
|
@ -4,7 +4,7 @@
|
|||
"test": {
|
||||
"presets": [
|
||||
["env", {
|
||||
"targets": { "node": 7 }
|
||||
"targets": { "node": 9 }
|
||||
}],
|
||||
"stage-0"
|
||||
],
|
||||
|
@ -13,7 +13,7 @@
|
|||
"main": {
|
||||
"presets": [
|
||||
["env", {
|
||||
"targets": { "node": 7 }
|
||||
"targets": { "node": 9 }
|
||||
}],
|
||||
"stage-0"
|
||||
]
|
||||
|
|
|
@ -19,6 +19,5 @@ jobs:
|
|||
paths:
|
||||
- node_modules
|
||||
- run:
|
||||
name: Eslint
|
||||
command: NODE_ENV=production npm run lint
|
||||
|
||||
name: mocha
|
||||
command: npm run mocha
|
||||
|
|
|
@ -8085,9 +8085,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"growl": {
|
||||
"version": "1.10.3",
|
||||
"resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz",
|
||||
"integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==",
|
||||
"version": "1.10.5",
|
||||
"resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz",
|
||||
"integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==",
|
||||
"dev": true
|
||||
},
|
||||
"handle-thing": {
|
||||
|
@ -11202,43 +11202,37 @@
|
|||
}
|
||||
},
|
||||
"mocha": {
|
||||
"version": "5.1.1",
|
||||
"resolved": "https://registry.npmjs.org/mocha/-/mocha-5.1.1.tgz",
|
||||
"integrity": "sha512-kKKs/H1KrMMQIEsWNxGmb4/BGsmj0dkeyotEvbrAuQ01FcWRLssUNXCEUZk6SZtyJBi6EE7SL0zDDtItw1rGhw==",
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz",
|
||||
"integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"browser-stdout": "1.3.1",
|
||||
"commander": "2.11.0",
|
||||
"commander": "2.15.1",
|
||||
"debug": "3.1.0",
|
||||
"diff": "3.5.0",
|
||||
"escape-string-regexp": "1.0.5",
|
||||
"glob": "7.1.2",
|
||||
"growl": "1.10.3",
|
||||
"growl": "1.10.5",
|
||||
"he": "1.1.1",
|
||||
"minimatch": "3.0.4",
|
||||
"mkdirp": "0.5.1",
|
||||
"supports-color": "4.4.0"
|
||||
"supports-color": "5.4.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"commander": {
|
||||
"version": "2.11.0",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz",
|
||||
"integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==",
|
||||
"dev": true
|
||||
},
|
||||
"has-flag": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz",
|
||||
"integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=",
|
||||
"version": "2.15.1",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz",
|
||||
"integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==",
|
||||
"dev": true
|
||||
},
|
||||
"supports-color": {
|
||||
"version": "4.4.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz",
|
||||
"integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==",
|
||||
"version": "5.4.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz",
|
||||
"integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"has-flag": "2.0.0"
|
||||
"has-flag": "3.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,8 @@
|
|||
"pack:renderer": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.renderer.config.js",
|
||||
"test": "npm run unit && npm run e2e",
|
||||
"unit": "karma start test/unit/karma.conf.js",
|
||||
"postinstall": "npm run lint:fix"
|
||||
"postinstall": "npm run lint:fix",
|
||||
"mocha": "BABEL_ENV=test mocha --require babel-register --recursive ./test/mocha/**/*.js"
|
||||
},
|
||||
"build": {
|
||||
"productName": "Whalebird",
|
||||
|
@ -160,7 +161,7 @@
|
|||
"karma-sourcemap-loader": "^0.3.7",
|
||||
"karma-spec-reporter": "^0.0.31",
|
||||
"karma-webpack": "^2.0.1",
|
||||
"mocha": "^5.1.1",
|
||||
"mocha": "^5.2.0",
|
||||
"multispinner": "^0.2.1",
|
||||
"node-loader": "^0.6.0",
|
||||
"node-sass": "^4.9.0",
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
<script>
|
||||
import { mapState } from 'vuex'
|
||||
import { domainFormat } from '../../utils/validator'
|
||||
|
||||
export default {
|
||||
name: 'login-form',
|
||||
|
@ -45,7 +46,7 @@ export default {
|
|||
message: 'Domain name is required'
|
||||
},
|
||||
{
|
||||
pattern: /^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,}$/,
|
||||
pattern: domainFormat,
|
||||
trigger: 'change',
|
||||
message: 'Please write only domain name'
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
export const domainFormat = new RegExp(/^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,}$/)
|
|
@ -0,0 +1,42 @@
|
|||
var assert = require('assert')
|
||||
import { domainFormat } from '../../src/renderer/utils/validator'
|
||||
|
||||
describe('validator', () => {
|
||||
describe('domainFormat', () => {
|
||||
context('string contains protocol', () => {
|
||||
const domain = 'https://mastodon.social'
|
||||
it('should not match', () => {
|
||||
const res = domain.search(domainFormat)
|
||||
assert.equal(res, -1)
|
||||
})
|
||||
})
|
||||
context('string contains account name', () => {
|
||||
const domain = 'h3_poteto@mastodon.social'
|
||||
it('should not match', () => {
|
||||
const res = domain.search(domainFormat)
|
||||
assert.equal(res, -1)
|
||||
})
|
||||
})
|
||||
context('string is gTLD domain', () => {
|
||||
const domain = 'mastodon.social'
|
||||
it('should match', () => {
|
||||
const res = domain.search(domainFormat)
|
||||
assert.equal(res, 0)
|
||||
})
|
||||
})
|
||||
context('string is subdomain', () => {
|
||||
const domain = 'music.mastodon.social'
|
||||
it('should match', () => {
|
||||
const res = domain.search(domainFormat)
|
||||
assert.equal(res, 0)
|
||||
})
|
||||
})
|
||||
context('string is jp domain', () => {
|
||||
const domain = 'mstdn.co.jp'
|
||||
it('should match', () => {
|
||||
const res = domain.search(domainFormat)
|
||||
assert.equal(res, 0)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
|
@ -9,5 +9,5 @@ testsContext.keys().forEach(testsContext)
|
|||
// require all src files except main.js for coverage.
|
||||
// you can also change this to match only the subset of files that
|
||||
// you want coverage for.
|
||||
const srcContext = require.context('../../src/renderer', true, /^\.\/(?!main(\.js)?$)/)
|
||||
const srcContext = require.context('../../src/renderer', true, /^(?!.*(main\.js|~|\.scss)).*$/)
|
||||
srcContext.keys().forEach(srcContext)
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import Vue from 'vue'
|
||||
import LandingPage from '@/components/LandingPage'
|
||||
// import Vue from 'vue'
|
||||
// import LandingPage from '@/components/LandingPage'
|
||||
|
||||
describe('LandingPage.vue', () => {
|
||||
it('should render correct contents', () => {
|
||||
const vm = new Vue({
|
||||
el: document.createElement('div'),
|
||||
render: h => h(LandingPage)
|
||||
}).$mount()
|
||||
// describe('LandingPage.vue', () => {
|
||||
// it('should render correct contents', () => {
|
||||
// const vm = new Vue({
|
||||
// el: document.createElement('div'),
|
||||
// render: h => h(LandingPage)
|
||||
// }).$mount()
|
||||
|
||||
expect(vm.$el.querySelector('.title').textContent).to.contain('Welcome to your new project!')
|
||||
})
|
||||
})
|
||||
// expect(vm.$el.querySelector('.title').textContent).to.contain('Welcome to your new project!')
|
||||
// })
|
||||
// })
|
||||
|
|
Loading…
Reference in New Issue