5 |
5 |
}
|
6 |
6 |
|
7 |
7 |
QUnit.test("kivi.parse_time function for German time style with colon", function( assert ) {
|
|
8 |
assert.equalTimes = function(actual, expected, message) {
|
|
9 |
console.log(this);
|
|
10 |
var result = (expected === undefined && actual === undefined)
|
|
11 |
|| (expected === null && actual === null)
|
|
12 |
|| (expected instanceof Date && actual instanceof Date &&
|
|
13 |
expected.getHours() == actual.getHours() &&
|
|
14 |
expected.getMinutes() == actual.getMinutes());
|
|
15 |
|
|
16 |
this.push( {
|
|
17 |
result: result,
|
|
18 |
actual: actual,
|
|
19 |
expected: expected,
|
|
20 |
message: message
|
|
21 |
} );
|
|
22 |
}
|
|
23 |
|
8 |
24 |
kivi.setup_formats({ times: "hh:mm" });
|
9 |
25 |
|
10 |
|
assert.deepEqual(kivi.parse_time("12:34"), custom_time(12,34));
|
11 |
|
assert.deepEqual(kivi.parse_time("10:00"), custom_time(10,0));
|
12 |
|
assert.deepEqual(kivi.parse_time(" 12 : 23 "), custom_time(12,23));
|
|
26 |
assert.equalTimes(kivi.parse_time("12:34"), custom_time(12,34));
|
|
27 |
assert.equalTimes(kivi.parse_time("10:00"), custom_time(10,0));
|
|
28 |
assert.equalTimes(kivi.parse_time(" 12 : 23 ") - custom_time(12,23));
|
13 |
29 |
|
14 |
|
assert.deepEqual(kivi.parse_time("00:20"), custom_time(0,20));
|
|
30 |
assert.equalTimes(kivi.parse_time("00:20"), custom_time(0,20));
|
15 |
31 |
|
16 |
|
assert.deepEqual(kivi.parse_time("23:60"), custom_time(23,60));
|
|
32 |
assert.equalTimes(kivi.parse_time("23:60"), custom_time(23,60));
|
17 |
33 |
|
18 |
|
assert.deepEqual(kivi.parse_time("1142"), custom_time(11,42));
|
|
34 |
assert.equalTimes(kivi.parse_time("1142"), custom_time(11,42));
|
19 |
35 |
|
20 |
|
assert.deepEqual(kivi.parse_time("Totally Invalid!"), undefined);
|
21 |
|
assert.deepEqual(kivi.parse_time("."), undefined);
|
22 |
|
assert.deepEqual(kivi.parse_time(".."), undefined);
|
23 |
|
assert.deepEqual(kivi.parse_time(":"), custom_time(0,0));
|
24 |
|
assert.deepEqual(kivi.parse_time("::"), undefined);
|
25 |
|
assert.deepEqual(kivi.parse_time(""), null);
|
26 |
|
assert.deepEqual(kivi.parse_time("0"), new Date());
|
27 |
|
assert.deepEqual(kivi.parse_time("29:20008"), custom_time(29,20008));
|
|
36 |
assert.equalTimes(kivi.parse_time("Totally Invalid!"), undefined);
|
|
37 |
assert.equalTimes(kivi.parse_time("."), undefined);
|
|
38 |
assert.equalTimes(kivi.parse_time(".."), undefined);
|
|
39 |
assert.equalTimes(kivi.parse_time(":"), undefined);
|
|
40 |
assert.equalTimes(kivi.parse_time("::"), undefined);
|
|
41 |
assert.equalTimes(kivi.parse_time("aa:bb"), undefined);
|
|
42 |
assert.equalTimes(kivi.parse_time("aasd:bbaf"), undefined);
|
|
43 |
assert.equalTimes(kivi.parse_time(""), null);
|
|
44 |
assert.equalTimes(kivi.parse_time("0"), new Date());
|
|
45 |
assert.equalTimes(kivi.parse_time("29:20008"), custom_time(29,20008));
|
28 |
46 |
});
|
29 |
47 |
|
Validator: time - striktere Prüfung und tests