~smagoun/whoopsie/whoopsie-lp1017637

« back to all changes in this revision

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

  • Committer: Evan Dandrea
  • Date: 2012-05-09 05:53:45 UTC
  • Revision ID: evan.dandrea@canonical.com-20120509055345-z2j41tmcbf4as5uf
The backend now lives in lp:daisy and the website (errors.ubuntu.com) now lives in lp:errors.

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.weeks");
10
 
 
11
 
suite.addBatch({
12
 
  "weeks": {
13
 
    topic: function() {
14
 
      return d3.time.weeks;
15
 
    },
16
 
    "returns sundays": function(range) {
17
 
      assert.deepEqual(range(local(2010, 11, 21), local(2011, 0, 12)), [
18
 
        local(2010, 11, 26),
19
 
        local(2011, 0, 2),
20
 
        local(2011, 0, 9)
21
 
      ]);
22
 
    },
23
 
    "has an inclusive lower bound": function(range) {
24
 
      assert.deepEqual(range(local(2010, 11, 21), local(2011, 0, 12))[0], local(2010, 11, 26));
25
 
    },
26
 
    "has an exclusive upper bound": function(range) {
27
 
      assert.deepEqual(range(local(2010, 11, 21), local(2011, 0, 12))[2], local(2011, 0, 9));
28
 
    },
29
 
    "can skip weeks": function(range) {
30
 
      assert.deepEqual(range(local(2011, 0, 1), local(2011, 3, 1), 4), [
31
 
        local(2011, 0, 2),
32
 
        local(2011, 0, 30),
33
 
        local(2011, 1, 27),
34
 
        local(2011, 2, 27)
35
 
      ]);
36
 
    },
37
 
    "observes start of daylight savings time": function(range) {
38
 
      assert.deepEqual(range(local(2011, 2, 1), local(2011, 2, 28)), [
39
 
        local(2011, 2, 6),
40
 
        local(2011, 2, 13),
41
 
        local(2011, 2, 20),
42
 
        local(2011, 2, 27)
43
 
      ]);
44
 
    },
45
 
    "observes end of daylight savings time": function(range) {
46
 
      assert.deepEqual(range(local(2011, 10, 1), local(2011, 10, 30)), [
47
 
        local(2011, 10, 6),
48
 
        local(2011, 10, 13),
49
 
        local(2011, 10, 20),
50
 
        local(2011, 10, 27)
51
 
      ]);
52
 
    },
53
 
    "UTC": {
54
 
      topic: function(range) {
55
 
        return range.utc;
56
 
      },
57
 
      "returns sundays": function(range) {
58
 
        assert.deepEqual(range(utc(2010, 11, 21), utc(2011, 0, 12)), [
59
 
          utc(2010, 11, 26),
60
 
          utc(2011, 0, 2),
61
 
          utc(2011, 0, 9)
62
 
        ]);
63
 
      },
64
 
      "has an inclusive lower bound": function(range) {
65
 
        assert.deepEqual(range(utc(2010, 11, 21), utc(2011, 0, 12))[0], utc(2010, 11, 26));
66
 
      },
67
 
      "has an exclusive upper bound": function(range) {
68
 
        assert.deepEqual(range(utc(2010, 11, 21), utc(2011, 0, 12))[2], utc(2011, 0, 9));
69
 
      },
70
 
      "can skip weeks": function(range) {
71
 
        assert.deepEqual(range(utc(2011, 0, 1), utc(2011, 3, 1), 4), [
72
 
          utc(2011, 0, 2),
73
 
          utc(2011, 0, 30),
74
 
          utc(2011, 1, 27),
75
 
          utc(2011, 2, 27)
76
 
        ]);
77
 
      },
78
 
      "does not observe the start of daylight savings time": function(range) {
79
 
        assert.deepEqual(range(utc(2011, 2, 1), utc(2011, 2, 28)), [
80
 
          utc(2011, 2, 6),
81
 
          utc(2011, 2, 13),
82
 
          utc(2011, 2, 20),
83
 
          utc(2011, 2, 27)
84
 
        ]);
85
 
      },
86
 
      "does not observe the end of daylight savings time": function(range) {
87
 
        assert.deepEqual(range(utc(2011, 10, 1), utc(2011, 10, 30)), [
88
 
          utc(2011, 10, 6),
89
 
          utc(2011, 10, 13),
90
 
          utc(2011, 10, 20),
91
 
          utc(2011, 10, 27)
92
 
        ]);
93
 
      }
94
 
    }
95
 
  }
96
 
});
97
 
 
98
 
suite.export(module);