-
Notifications
You must be signed in to change notification settings - Fork 4
/
custom-notations.spec.ts
92 lines (73 loc) · 2.88 KB
/
custom-notations.spec.ts
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
import {CaretString, Mask, Notation} from '../src';
import {assert} from 'chai';
import '../src/util/input-event';
describe('Custom Notations', function () {
const hourCustomNotations = [
new Notation(
'H',
['0', '1', '2'],
true
),
new Notation(
'h',
['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
true
),
new Notation(
'M',
['0', '1', '2', '3', '4', '5', '7', '8', '9'],
false
),
new Notation(
'm',
['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
false
)
];
const hourMask = Mask.getOrCreate('[Hh]{:}[Mm]', hourCustomNotations);
it('should return "1" with input "1"', function () {
const inputStr = '1';
const result = hourMask.apply(new CaretString(inputStr, inputStr.length), true);
assert.equal(result.extractedValue, '1');
});
it('should return "12:" with input "12"', function () {
const inputStr = '12';
const result = hourMask.apply(new CaretString(inputStr, inputStr.length), true);
assert.equal(result.extractedValue, '12:');
});
it('should return "12:5" with input "125"', function () {
const inputStr = '125';
const result = hourMask.apply(new CaretString(inputStr, inputStr.length), true);
assert.equal(result.extractedValue, '12:5');
});
it('should return "12:59" with input "1259"', function () {
const inputStr = '1259';
const result = hourMask.apply(new CaretString(inputStr, inputStr.length), true);
assert.equal(result.extractedValue, '12:59');
});
it('should return "0" with input "0"', function () {
const inputStr = '0';
const result = hourMask.apply(new CaretString(inputStr, inputStr.length), true);
assert.equal(result.extractedValue, '0');
});
it('should return "0:" with input "0:"', function () {
const inputStr = '0:';
const result = hourMask.apply(new CaretString(inputStr, inputStr.length), true);
assert.equal(result.extractedValue, '0:');
});
it('should return "0:" with input "0:6"', function () {
const inputStr = '0:6';
const result = hourMask.apply(new CaretString(inputStr, inputStr.length), true);
assert.equal(result.extractedValue, '0:');
});
it('should return "0:5" with input "0:5"', function () {
const inputStr = '0:5';
const result = hourMask.apply(new CaretString(inputStr, inputStr.length), true);
assert.equal(result.extractedValue, '0:5');
});
it('should return "0:59" with input "0:59"', function () {
const inputStr = '0:59';
const result = hourMask.apply(new CaretString(inputStr, inputStr.length), true);
assert.equal(result.extractedValue, '0:59');
});
})