Skip to content

Commit

Permalink
use runtime only build
Browse files Browse the repository at this point in the history
  • Loading branch information
Charlie Kassel committed Jun 26, 2017
1 parent 650ef70 commit a0fad71
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 79 deletions.
3 changes: 2 additions & 1 deletion build/webpack.base.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ module.exports = {
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'vue$': 'vue/dist/vue.esm.js',
// compiler included build
// 'vue$': 'vue/dist/vue.esm.js',
'@': resolve('src')
}
},
Expand Down
3 changes: 0 additions & 3 deletions src/Demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,6 @@ export default {
}
this.disabled.from = val
}
},
created () {
console.log(this.languages)
}
}
</script>
Expand Down
2 changes: 0 additions & 2 deletions test/unit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@ testsContext.keys().forEach(testsContext)
// you want coverage for.
const srcContext = require.context('../../src', true, /^\.\/(?!main|Demo(\.js|\.vue)?$)/)

console.log(srcContext.keys())

srcContext.keys().forEach(srcContext)
100 changes: 27 additions & 73 deletions test/unit/specs/Datepicker.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* global describe, it, expect, beforeEach */

import Vue from 'vue'
import Datepicker from '../../../src/components/Datepicker.vue'
import Datepicker from '@/components/Datepicker.vue'

let vm

Expand Down Expand Up @@ -106,31 +106,22 @@ describe('Datepicker.vue', () => {
})
})

it('should close when clicked outside', async () => {
vm.showDayCalendar()
expect(vm.isOpen).to.equal(true)
vm.showDayCalendar()
expect(vm.showDayView).to.equal(true)
document.body.click()
expect(vm.isOpen).to.equal(false)
it('should render correct contents', async () => {
await vm.$nextTick(() => {
expect(vm.$el.querySelectorAll('.vdp-datepicker').length).to.equal(1)
expect(vm.$el.querySelectorAll('input').length).to.equal(1)
})
})

// it('should render correct contents', async () => {
// await vm.$nextTick(() => {
// expect(vm.$el.querySelectorAll('.vdp-datepicker').length).to.equal(1)
// expect(vm.$el.querySelectorAll('input').length).to.equal(1)
// })
// })

// it('should set currdate to be now', async () => {
// await vm.$nextTick(() => {
// const data = Datepicker.data()
// const d = new Date(data.currDate)
// expect(d.getFullYear()).to.equal(new Date().getFullYear())
// expect(d.getMonth()).to.equal(new Date().getMonth())
// expect(d.getDate()).to.equal(1)
// })
// })
it('should set currdate to be now', async () => {
await vm.$nextTick(() => {
const data = Datepicker.data()
const d = new Date(data.currDate)
expect(d.getFullYear()).to.equal(new Date().getFullYear())
expect(d.getMonth()).to.equal(new Date().getMonth())
expect(d.getDate()).to.equal(1)
})
})

it('should open and close the calendar', () => {
vm.close()
Expand Down Expand Up @@ -235,60 +226,23 @@ describe('Datepicker.vue', () => {
})
})

describe('Datepicker.vue set by object', () => {
let state
beforeEach(() => {
state = {
value: new Date(2016, 1, 20),
format: 'yyyy-MM-dd'
}
vm = new Vue({
template: '<div><datepicker :value="value" :format="format"></datepicker></div>',
components: { Datepicker },
data: function () {
return state
}
}).$mount()
})

it('should allow value to be changed outside of component', (done) => {
state.value = new Date(2016, 2, 15)
vm.$nextTick(() => {
expect(vm.$el.querySelector('input').value).to.equal('2016-03-15')
done()
})
})
})

describe('Datepicker.vue set by string', () => {
let state
beforeEach(() => {
state = {
value: '2016-02-20',
format: 'yyyy-MM-dd'
}
vm = new Vue({
template: '<div><datepicker :value="value" :format="format"></datepicker></div>',
components: { Datepicker },
data: function () {
return state
}
}).$mount()
})

it('should allow value to be changed outside of component', (done) => {
state.value = '2016-03-15'
vm.$nextTick(() => {
expect(vm.$el.querySelector('input').value).to.equal('2016-03-15')
done()
it('can parse a string date', async () => {
vm = getViewModel(Datepicker, {
format: 'yyyy MM dd',
value: '2016-02-20'
})
await vm.$nextTick(() => {
expect(vm.$el.querySelector('input').value).to.equal('2016 02 20')
})
})

it('should allow malformed value', (done) => {
state.value = 'today'
vm.$nextTick(() => {
it('should allow malformed value', async () => {
vm = getViewModel(Datepicker, {
value: 'today'
})
await vm.$nextTick(() => {
expect(vm.$el.querySelector('input').value).to.equal('')
done()
})
})
})
Expand Down

0 comments on commit a0fad71

Please sign in to comment.