-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathclear.js
94 lines (82 loc) · 2.29 KB
/
clear.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import {
$,
$input,
safeDispose,
fromData,
assertData,
assertText,
findPopper,
findToday,
assertNotFound,
assertVisible,
assertHidden,
assertDatesEqual,
findDayOfMonth,
prepare,
YYYY_MM_DD,
findMonthsSwitch,
findYearsSwitch,
findDecadesSwitch,
findCenturiesSwitch
} from '../../support'
import {Selector, ClassName} from '../../../js/constants'
import moment from 'moment'
describe('Datepicker', () => {
beforeEach(() => prepare())
afterEach(() => safeDispose())
describe('clear', () => {
describe('button', () => {
it(`should not show by default`, () => {
$input.datepicker()
assertData().show()
assertVisible(Selector.DAYS)
assertHidden(`${Selector.DAYS} tfoot ${Selector.CLEAR}`)
})
it(`should show when enabled`, () => {
$input.datepicker({
button: {clear: true}
})
assertData().show()
assertVisible(Selector.DAYS)
assertVisible(`${Selector.DAYS} tfoot ${Selector.CLEAR}`)
findMonthsSwitch().click()
assertVisible(Selector.MONTHS)
assertVisible(`${Selector.MONTHS} tfoot ${Selector.CLEAR}`)
findYearsSwitch().click()
assertVisible(Selector.YEARS)
assertVisible(`${Selector.YEARS} tfoot ${Selector.CLEAR}`)
})
it(`should clear the input value`, () => {
$input.val(`2012-03-05`)
.datepicker({
format: YYYY_MM_DD,
button: {clear: true}
})
let dp = assertData()
dp.show()
assertVisible(Selector.DAYS)
// click clear
assertVisible(`${Selector.DAYS} tfoot ${Selector.CLEAR}`).click()
assertText('input', '')
expect(dp.getDate()).to.be.null
assertVisible(Selector.POPPER)
})
it(`should hide with autoclose true`, () => {
$input.val(`2012-03-05`)
.datepicker({
format: YYYY_MM_DD,
button: {clear: true},
autoclose: true
})
let dp = assertData()
dp.show()
assertVisible(Selector.DAYS)
// click clear
assertVisible(`${Selector.DAYS} tfoot ${Selector.CLEAR}`).click()
assertText('input', '')
expect(dp.getDate()).to.be.null
assertNotFound(Selector.POPPER)
})
})
})
})