1 | var vows = require('vows');
|
2 | var assert = require('assert');
|
3 |
|
4 | require('../lib/date-utils.js');
|
5 |
|
6 | vows.describe('Date New').addBatch({
|
7 | 'can return a new object from today static method': {
|
8 | topic: function () { return Date.today(); },
|
9 | 'returns the correct time': function (date) {
|
10 | var compare = new Date().clearTime();
|
11 | assert.equal(date.valueOf(), compare.valueOf());
|
12 | }
|
13 | },
|
14 |
|
15 | 'clearTime() works': {
|
16 | topic: function() { return new Date().clearTime(); },
|
17 | 'returns the correct value': function (date) {
|
18 | var compare = new Date();
|
19 | compare.setHours(0);
|
20 | compare.setMinutes(0);
|
21 | compare.setSeconds(0);
|
22 | compare.setMilliseconds(0);
|
23 |
|
24 | assert.equal(date.valueOf(), compare.valueOf());
|
25 | }
|
26 | },
|
27 |
|
28 | 'clearUTCTime() works': {
|
29 | topic: function() { return new Date().clearUTCTime(); },
|
30 | 'returns the correct value': function (date) {
|
31 | var compare = new Date();
|
32 | compare.setUTCHours(0);
|
33 | compare.setUTCMinutes(0);
|
34 | compare.setUTCSeconds(0);
|
35 | compare.setUTCMilliseconds(0);
|
36 |
|
37 | assert.equal(date.valueOf(), compare.valueOf());
|
38 | }
|
39 | },
|
40 |
|
41 | 'today() works': {
|
42 | topic: function() {
|
43 | return Date.today();
|
44 | },
|
45 | 'returns the correct value': function(date) {
|
46 | var compare = new Date().clearTime();
|
47 | assert.equal(date.valueOf(), compare.valueOf());
|
48 | }
|
49 | },
|
50 |
|
51 | 'UTCtoday() works': {
|
52 | topic: function() {
|
53 | return Date.UTCtoday();
|
54 | },
|
55 | 'returns the correct value': function(date) {
|
56 | var compare = new Date().clearUTCTime();
|
57 | assert.equal(date.valueOf(), compare.valueOf());
|
58 | }
|
59 | },
|
60 |
|
61 | 'yesterday() works': {
|
62 | topic: function() {
|
63 | return Date.yesterday();
|
64 | },
|
65 | 'returns the correct value': function(date) {
|
66 | var compare = new Date().clearTime();
|
67 | compare.setSeconds(compare.getSeconds() - 86400);
|
68 | assert.equal(date.valueOf(), compare.valueOf());
|
69 | }
|
70 | },
|
71 |
|
72 | 'UTCyesterday() works': {
|
73 | topic: function() {
|
74 | return Date.UTCyesterday();
|
75 | },
|
76 | 'returns the correct value': function(date) {
|
77 | var compare = new Date().clearUTCTime();
|
78 | compare.setSeconds(compare.getSeconds() - 86400);
|
79 | assert.equal(date.valueOf(), compare.valueOf());
|
80 | }
|
81 | },
|
82 |
|
83 | 'tomorrow() works': {
|
84 | topic: function() {
|
85 | return Date.tomorrow();
|
86 | },
|
87 | 'returns the correct value': function(date) {
|
88 | var compare = new Date().clearTime();
|
89 | compare.setSeconds(compare.getSeconds() + 86400);
|
90 | assert.equal(date.valueOf(), compare.valueOf());
|
91 | }
|
92 | },
|
93 |
|
94 | 'UTCtomorrow() works': {
|
95 | topic: function() {
|
96 | return Date.UTCtomorrow();
|
97 | },
|
98 | 'returns the correct value': function(date) {
|
99 | var compare = new Date().clearUTCTime();
|
100 | compare.setSeconds(compare.getSeconds() + 86400);
|
101 | assert.equal(date.valueOf(), compare.valueOf());
|
102 | }
|
103 | }
|
104 |
|
105 | }).export(module); |
\ | No newline at end of file |