]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/web/js/ui/default/staff/test/unit/egDate.js
5802e2d90cfc4fcfd17f5a4f16717cebd9d936a9
[working/Evergreen.git] / Open-ILS / web / js / ui / default / staff / test / unit / egDate.js
1 'use strict';
2
3 describe('egDate', function(){
4     beforeEach(module('egCoreMod'));
5
6     beforeEach(function () {
7         this.addMatchers({
8
9             // "2 days" may be 47, 48, or 49 hours depending on the 
10             // proximity to and direction of a time change event.
11             // This does not take leap seconds into account.
12             toBe2DaysOfSeconds: function () {
13                 var actual = this.actual;
14                 var hours_47 = 169200;
15                 var hours_48 = 172800;
16                 var hours_49 = 176400;
17
18                 this.message = function () {
19                     return "Expected " + actual + " to be " + 
20                         hours_47 + ", " + hours_48 + ", or " + hours_49;
21                 };
22
23                 return (
24                     actual == hours_47 || 
25                     actual == hours_48 || 
26                     actual == hours_49
27                 );
28             }
29         });
30     });
31
32     it('should parse a simple interval', inject(function(egDate) {
33         expect(egDate.intervalToSeconds('2 days')).toBe2DaysOfSeconds();
34     }));
35
36     it('should parse a combined interval', inject(function(egDate) {
37         expect(egDate.intervalToSeconds('1 min 2 seconds')).toBe(62);
38     }));
39
40     it('should parse a time interval', inject(function(egDate) {
41         expect(egDate.intervalToSeconds('02:00:23')).toBe(7223);
42     }));
43
44 });