]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/web/js/ui/default/staff/test/unit/egDate.js
LP#1739803 Angular 1.6 + dependency updates
[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         jasmine.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                 return {
14                     compare : function(actual) {
15                         var hours_47 = 169200;
16                         var hours_48 = 172800;
17                         var hours_49 = 176400;
18
19                         var passed = (
20                             actual == hours_47 || 
21                             actual == hours_48 || 
22                             actual == hours_49
23                         );
24
25                         return {
26                             pass: passed,
27                             message: "Expected " + actual + " to be " + 
28                                 hours_47 + ", " + hours_48 + ", or " + hours_49
29                         };
30                     }
31                 };
32             }
33         });
34     });
35
36     it('should parse a simple interval', inject(function(egDate) {
37         expect(egDate.intervalToSeconds('2 days')).toBe2DaysOfSeconds();
38     }));
39
40     it('should parse a combined interval', inject(function(egDate) {
41         expect(egDate.intervalToSeconds('1 min 2 seconds')).toBe(62);
42     }));
43
44     it('should parse a time interval', inject(function(egDate) {
45         expect(egDate.intervalToSeconds('02:00:23')).toBe(7223);
46     }));
47
48 });