~ubuntu-branches/ubuntu/precise/whoopsie-daisy/precise-proposed

« back to all changes in this revision

Viewing changes to backend/stats/static/js/d3/test/time/hours-test.js

  • Committer: Package Import Robot
  • Author(s): Evan Dandrea
  • Date: 2012-04-10 14:28:58 UTC
  • Revision ID: package-import@ubuntu.com-20120410142858-nk453o1z7t7py3bs
Tags: 0.1.26
* Take ownership of the NetworkManager state variant on setup and
  unref it, plugging a memory leak.
* Log the reason the server rejected the submitted crash report.
* Send the Whoopsie version with each crash submission.
* Delete both .upload and .uploaded files after 14 days. Thanks
  Marc Deslauriers (LP: #973687).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require("../env");
 
2
 
 
3
var vows = require("vows"),
 
4
    assert = require("assert"),
 
5
    time = require("./time"),
 
6
    local = time.local,
 
7
    utc = time.utc;
 
8
 
 
9
var suite = vows.describe("d3.time.hours");
 
10
 
 
11
suite.addBatch({
 
12
  "hours": {
 
13
    topic: function() {
 
14
      return d3.time.hours;
 
15
    },
 
16
    "returns hours": function(range) {
 
17
      assert.deepEqual(range(local(2010, 11, 31, 12, 30), local(2010, 11, 31, 15, 30)), [
 
18
        local(2010, 11, 31, 13),
 
19
        local(2010, 11, 31, 14),
 
20
        local(2010, 11, 31, 15)
 
21
      ]);
 
22
    },
 
23
    "has an inclusive lower bound": function(range) {
 
24
      assert.deepEqual(range(local(2010, 11, 31, 23), local(2011, 0, 1, 2))[0], local(2010, 11, 31, 23));
 
25
    },
 
26
    "has an exclusive upper bound": function(range) {
 
27
      assert.deepEqual(range(local(2010, 11, 31, 23), local(2011, 0, 1, 2))[2], local(2011, 0, 1, 1));
 
28
    },
 
29
    "can skip hours": function(range) {
 
30
      assert.deepEqual(range(local(2011, 1, 1, 1), local(2011, 1, 1, 13), 3), [
 
31
        local(2011, 1, 1, 3),
 
32
        local(2011, 1, 1, 6),
 
33
        local(2011, 1, 1, 9),
 
34
        local(2011, 1, 1, 12)
 
35
      ]);
 
36
    },
 
37
    "observes start of daylight savings time": function(range) {
 
38
      assert.deepEqual(range(local(2011, 2, 13, 1), local(2011, 2, 13, 5)), [
 
39
        utc(2011, 2, 13, 9),
 
40
        utc(2011, 2, 13, 10),
 
41
        utc(2011, 2, 13, 11)
 
42
      ]);
 
43
    },
 
44
    "observes end of daylight savings time": function(range) {
 
45
      assert.deepEqual(range(local(2011, 10, 6, 0), local(2011, 10, 6, 2)), [
 
46
        utc(2011, 10, 6, 7),
 
47
        utc(2011, 10, 6, 8),
 
48
        utc(2011, 10, 6, 9)
 
49
      ]);
 
50
    },
 
51
    "NPT": {
 
52
      "observes 15-minute offset": tz("Asia/Kathmandu", function(range) {
 
53
        assert.deepEqual(range(local(2011, 10, 7, 0), local(2011, 10, 7, 3)), [
 
54
          utc(2011, 10, 6, 18, 15),
 
55
          utc(2011, 10, 6, 19, 15),
 
56
          utc(2011, 10, 6, 20, 15)
 
57
        ]);
 
58
      })
 
59
    },
 
60
    "IST": {
 
61
      "observes 30-minute offset": tz("Asia/Calcutta", function(range) {
 
62
        assert.deepEqual(range(local(2011, 10, 7, 0), local(2011, 10, 7, 3)), [
 
63
          utc(2011, 10, 6, 18, 30),
 
64
          utc(2011, 10, 6, 19, 30),
 
65
          utc(2011, 10, 6, 20, 30)
 
66
        ]);
 
67
      })
 
68
    },
 
69
    "UTC": {
 
70
      topic: function(range) {
 
71
        return range.utc;
 
72
      },
 
73
      "returns hours": function(range) {
 
74
        assert.deepEqual(range(utc(2010, 11, 31, 12, 30), utc(2010, 11, 31, 15, 30)), [
 
75
          utc(2010, 11, 31, 13),
 
76
          utc(2010, 11, 31, 14),
 
77
          utc(2010, 11, 31, 15)
 
78
        ]);
 
79
      },
 
80
      "has an inclusive lower bound": function(range) {
 
81
        assert.deepEqual(range(utc(2010, 11, 31, 23), utc(2011, 0, 1, 2))[0], utc(2010, 11, 31, 23));
 
82
      },
 
83
      "has an exclusive upper bound": function(range) {
 
84
        assert.deepEqual(range(utc(2010, 11, 31, 23), utc(2011, 0, 1, 2))[2], utc(2011, 0, 1, 1));
 
85
      },
 
86
      "can skip hours": function(range) {
 
87
        assert.deepEqual(range(utc(2011, 1, 1, 1), utc(2011, 1, 1, 13), 3), [
 
88
          utc(2011, 1, 1, 3),
 
89
          utc(2011, 1, 1, 6),
 
90
          utc(2011, 1, 1, 9),
 
91
          utc(2011, 1, 1, 12)
 
92
        ]);
 
93
      },
 
94
      "observes start of daylight savings time": function(range) {
 
95
        assert.deepEqual(range(utc(2011, 2, 13, 9), utc(2011, 2, 13, 12)), [
 
96
          utc(2011, 2, 13, 9),
 
97
          utc(2011, 2, 13, 10),
 
98
          utc(2011, 2, 13, 11)
 
99
        ]);
 
100
      },
 
101
      "observes end of daylight savings time": function(range) {
 
102
        assert.deepEqual(range(utc(2011, 10, 6, 7), utc(2011, 10, 6, 10)), [
 
103
          utc(2011, 10, 6, 7),
 
104
          utc(2011, 10, 6, 8),
 
105
          utc(2011, 10, 6, 9)
 
106
        ]);
 
107
      }
 
108
    }
 
109
  }
 
110
});
 
111
 
 
112
function tz(tz, scope) {
 
113
  return function() {
 
114
    var o = process.env.TZ;
 
115
    try {
 
116
      process.env.TZ = tz;
 
117
      new Date(0).toString(); // invalidate node's dst cache
 
118
      new Date().toString();
 
119
      scope.apply(this, arguments);
 
120
    } finally {
 
121
      process.env.TZ = o;
 
122
      new Date(0).toString(); // invalidate node's dst cache
 
123
      new Date().toString();
 
124
    }
 
125
  };
 
126
}
 
127
 
 
128
suite.export(module);