Skip to content
This repository has been archived by the owner on Jan 7, 2022. It is now read-only.

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Filippo Conti committed Aug 13, 2018
1 parent 76fd1d9 commit 84f2b04
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions test/specs/DatetimeYearPicker.spec.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { DateTime } from 'luxon'
import { createVM } from '../helpers/utils.js'
import DatetimeYearPicker from 'src/DatetimeYearPicker.vue'

Expand Down Expand Up @@ -43,5 +44,49 @@ describe('DatetimeYearPicker.vue', function () {
vm.$$('.vdatetime-year-picker__list .vdatetime-year-picker__item')[110].click()
expect(vm.year).to.be.equal(2030)
})

it('should disable change event when year is disabled', function () {
const vm = createVM(this,
`<DatetimeYearPicker :min-date="minDate" :max-date="maxDate" :year="2018"></DatetimeYearPicker>`,
{
components: { DatetimeYearPicker },
data () {
return {
minDate: DateTime.fromISO('1920-01-01'),
maxDate: DateTime.fromISO('2000-12-01')
}
}
})
vm.$$('.vdatetime-year-picker__list .vdatetime-year-picker__item')[0].click()
expect(vm.year).not.to.be.equal(1918)
})
})

describe('min/max validation', function () {
it('should add disabled class', function () {
const vm = createVM(this,
`<DatetimeYearPicker :min-date="minDate" :max-date="maxDate" :year="2018"></DatetimeYearPicker>`,
{
components: { DatetimeYearPicker },
data () {
return {
minDate: DateTime.fromISO('2018-01-01'),
maxDate: DateTime.fromISO('2018-12-01')
}
}
})

const years = vm.$$('.vdatetime-year-picker__list .vdatetime-year-picker__item')
for (var i = 0; i < years.length; i++) {
const yearEl = years[i]
if (yearEl.textContent === '2018') {
expect(yearEl.className).to.have.string('vdatetime-year-picker__item--selected')
console.log(yearEl.textContent)
console.log(yearEl.className)
continue
}
expect(yearEl.className).to.have.string('vdatetime-year-picker__item--disabled')
}
})
})
})

0 comments on commit 84f2b04

Please sign in to comment.