cron 1.1.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,655 +0,0 @@
1
- var _ = require('lodash');
2
- var chai = require('chai');
3
- var expect = chai.expect;
4
- var _parser = require('../lib/cron-parser');
5
-
6
- describe('cron parser', function() {
7
- describe('parse', function() {
8
- var parser;
9
- beforeEach(function() {
10
- parser = new _parser();
11
- });
12
-
13
- describe('wildcards ', function() {
14
- it('should parse * * * * *', function() {
15
- var parse = parser.parse('* * * * *');
16
- expect(parse.fields.seconds).to.deep.equal([0]);
17
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
18
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
19
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
20
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
21
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
22
- });
23
-
24
- it('should parse * * * * * *', function() {
25
- var parse = parser.parse('* * * * * *');
26
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
27
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
28
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
29
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
30
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
31
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
32
- });
33
- });
34
-
35
- describe('seconds', function() {
36
- it('should parse 0 * * * * *', function() {
37
- var parse = parser.parse('0 * * * * *');
38
- expect(parse.fields.seconds).to.deep.equal([0]);
39
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
40
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
41
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
42
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
43
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
44
- });
45
-
46
- it('should parse 0,1,2,3,4,5 * * * * *', function() {
47
- var parse = parser.parse('0,1,2,3,4,5 * * * * *');
48
- expect(parse.fields.seconds).to.deep.equal([0, 1, 2, 3, 4, 5]);
49
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
50
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
51
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
52
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
53
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
54
- });
55
-
56
- it('should parse 0-5 * * * * *', function() {
57
- var parse = parser.parse('0-5 * * * * *');
58
- expect(parse.fields.seconds).to.deep.equal([0, 1, 2, 3, 4, 5]);
59
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
60
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
61
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
62
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
63
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
64
- });
65
-
66
- it('should parse */2 * * * * *', function() {
67
- var parse = parser.parse('*/2 * * * * *');
68
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 2));
69
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
70
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
71
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
72
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
73
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
74
- });
75
-
76
- it('should parse 0,1,2,3,4,5,10-15 * * * * *', function() {
77
- var parse = parser.parse('0,1,2,3,4,5,10-15 * * * * *');
78
- expect(parse.fields.seconds).to.deep.equal([0, 1, 2, 3, 4, 5].concat(_.range(10, 16, 1)));
79
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
80
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
81
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
82
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
83
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
84
- });
85
-
86
- it('shouldn\'t parse 60 * * * * *', function() {
87
- expect(function() {
88
- var parse = parser.parse('60 * * * * *');
89
- }).to.throw(Error);
90
- });
91
- });
92
-
93
- describe('minutes', function() {
94
- it('should parse * 0 * * * *', function() {
95
- var parse = parser.parse('* 0 * * * *');
96
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
97
- expect(parse.fields.minutes).to.deep.equal([0]);
98
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
99
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
100
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
101
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
102
- });
103
-
104
- it('should parse * 0,1,2,3,4,5 * * * *', function() {
105
- var parse = parser.parse('* 0,1,2,3,4,5 * * * *');
106
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
107
- expect(parse.fields.minutes).to.deep.equal([0, 1, 2, 3, 4, 5]);
108
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
109
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
110
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
111
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
112
- });
113
-
114
- it('should parse * 0-5 * * * *', function() {
115
- var parse = parser.parse('* 0-5 * * * *');
116
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
117
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 6, 1));
118
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
119
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
120
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
121
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
122
- });
123
-
124
- it('should parse * */2 * * * *', function() {
125
- var parse = parser.parse('* */2 * * * *');
126
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
127
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 2));
128
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
129
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
130
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
131
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
132
- });
133
-
134
- it('should parse * 0,1,2,3,4,5,10-15 * * * *', function() {
135
- var parse = parser.parse('* 0,1,2,3,4,5,10-15 * * * *');
136
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
137
- expect(parse.fields.minutes).to.deep.equal([0, 1, 2, 3, 4, 5].concat(_.range(10, 16, 1)));
138
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
139
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
140
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
141
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
142
- });
143
-
144
- it('shouldn\'t parse * 60 * * * *', function() {
145
- expect(function() {
146
- var parse = parser.parse('* 60 * * * *');
147
- }).to.throw;
148
- });
149
- });
150
-
151
- describe('hours', function() {
152
- it('should parse * * 0 * * *', function() {
153
- var parse = parser.parse('* * 0 * * *');
154
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
155
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
156
- expect(parse.fields.hours).to.deep.equal([0]);
157
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
158
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
159
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
160
- });
161
-
162
- it('should parse * * 0,1,2,3,4,5 * * *', function() {
163
- var parse = parser.parse('* * 0,1,2,3,4,5 * * *');
164
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
165
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
166
- expect(parse.fields.hours).to.deep.equal([0, 1, 2, 3, 4, 5]);
167
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
168
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
169
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
170
- });
171
-
172
- it('should parse * * 0-5 * * *', function() {
173
- var parse = parser.parse('* * 0-5 * * *');
174
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
175
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
176
- expect(parse.fields.hours).to.deep.equal(_.range(0, 6, 1));
177
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
178
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
179
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
180
- });
181
-
182
- it('should parse * * */2 * * *', function() {
183
- var parse = parser.parse('* * */2 * * *');
184
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
185
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
186
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 2));
187
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
188
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
189
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
190
- });
191
-
192
- it('should parse * * 0,1,2,9-11 * * *', function() {
193
- var parse = parser.parse('* * 0,1,2,9-11 * * *');
194
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
195
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
196
- expect(parse.fields.hours).to.deep.equal([0, 1, 2].concat(_.range(9, 12, 1)));
197
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
198
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
199
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
200
- });
201
-
202
- it('shouldn\'t parse * * 24 * * *', function() {
203
- expect(function() {
204
- var parse = parser.parse('* * 24 * * *');
205
- }).to.throw;
206
- });
207
-
208
- describe('for daylight savings time', function() {
209
- it('shouldn\'t get stuck on dst'); //mostly just a reminder to do a bunch of work around DST
210
- });
211
- });
212
-
213
- describe('day of month', function() {
214
- it('should parse * * * 1 * *', function() {
215
- var parse = parser.parse('* * * 1 * *');
216
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
217
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
218
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
219
- expect(parse.fields.dayOfMonth).to.deep.equal([1]);
220
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
221
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
222
- });
223
-
224
- it('should parse * * * 1,2,3,4,5 * *', function() {
225
- var parse = parser.parse('* * * 1,2,3,4,5 * *');
226
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
227
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
228
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
229
- expect(parse.fields.dayOfMonth).to.deep.equal([1, 2, 3, 4, 5]);
230
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
231
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
232
- });
233
-
234
- it('should parse * * * 1-5 * *', function() {
235
- var parse = parser.parse('* * * 1-5 * *');
236
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
237
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
238
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
239
- expect(parse.fields.dayOfMonth).to.deep.equal([1, 2, 3, 4, 5]);
240
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
241
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
242
- });
243
-
244
- it('should parse * * * */2 * *', function() {
245
- var parse = parser.parse('* * * */2 * *');
246
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
247
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
248
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
249
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 2)); //boundary is 31, obviously not for every month...
250
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
251
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
252
- });
253
-
254
- it('should parse * * * 1,2,9-11 * *', function() {
255
- var parse = parser.parse('* * * 1,2,9-11 * *');
256
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
257
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
258
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
259
- expect(parse.fields.dayOfMonth).to.deep.equal([1,2].concat(_.range(9, 12, 1)));
260
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
261
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
262
- });
263
-
264
- it('should parse * * * L * *');
265
- it('should parse * * * 15W * *');
266
-
267
- describe('for different months', function() {
268
- describe('jan', function() {
269
- it('should parse * * 0 31 * *');
270
-
271
- it('should parse * * 0 L * *');
272
-
273
- it('shouldn\'t parse * * 0 32 * *', function() {
274
- expect(function() {
275
- var parse = parser.parse('* * 0 32 * *');
276
- }).to.throw;
277
- });
278
- });
279
-
280
- describe('feb', function() {
281
- it('should parse * * 1 31 * *');
282
-
283
- it('should parse * * 1 L * *');
284
-
285
- it('shouldn\'t parse * * 1 29 * * when not leap year', function() {
286
- expect(function() {
287
- var parse = parser.parse('* * 1 25 * *');
288
- }).to.throw;
289
- });
290
-
291
- it('should parse * * 1 29 * * when leap year');
292
- });
293
-
294
- describe('mar', function() {
295
- it('should parse * * 2 31 * *');
296
- it('should parse * * 2 L * *');
297
- it('shouldn\'t parse * * 2 32 * *');
298
- });
299
-
300
- describe('apr', function() {
301
- it('should parse * * 3 30 * *');
302
- it('should parse * * 3 L * *');
303
- it('shouldn\'t parse * * 3 31 * *');
304
- });
305
-
306
- describe('may', function() {
307
- it('should parse * * 4 31 * *');
308
- it('should parse * * 4 L * *');
309
- it('shouldn\'t parse * * 4 32 * *');
310
- });
311
-
312
- describe('jun', function() {
313
- it('should parse * * 5 30 * *');
314
- it('should parse * * 5 L * *');
315
- it('shouldn\'t parse * * 5 31 * *');
316
- });
317
-
318
- describe('jul', function() {
319
- it('should parse * * 6 31 * *');
320
- it('should parse * * 6 L * *');
321
- it('shouldn\'t parse * * 6 32 * *');
322
- });
323
-
324
- describe('aug', function() {
325
- it('should parse * * 7 31 * *');
326
- it('should parse * * 7 L * *');
327
- it('shouldn\'t parse * * 7 32 * *');
328
- });
329
-
330
- describe('sep', function() {
331
- it('should parse * * 8 30 * *');
332
- it('should parse * * 8 L * *');
333
- it('shouldn\'t parse * * 8 31 * *');
334
- });
335
-
336
- describe('oct', function() {
337
- it('should parse * * 9 31 * *');
338
- it('should parse * * 9 L * *');
339
- it('shouldn\'t parse * * 9 32 * *');
340
- });
341
-
342
- describe('nov', function() {
343
- it('should parse * * 10 30 * *');
344
- it('should parse * * 10 L * *');
345
- it('shouldn\'t parse * * 10 31 * *');
346
- });
347
-
348
- describe('dec', function() {
349
- it('should parse * * 11 31 * *');
350
- it('should parse * * 11 L * *');
351
- it('shouldn\'t parse * * 11 32 * *');
352
- });
353
- });
354
- });
355
-
356
- describe('month', function() {
357
- it('should parse * * * * 1 *', function() {
358
- var parse = parser.parse('* * * * 1 *');
359
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
360
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
361
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
362
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
363
- expect(parse.fields.month).to.deep.equal([1]);
364
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
365
- });
366
-
367
- it('should parse * * * * 1,2,3,4,5 *', function() {
368
- var parse = parser.parse('* * * * 1,2,3,4,5 *');
369
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
370
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
371
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
372
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
373
- expect(parse.fields.month).to.deep.equal([1, 2, 3, 4, 5]);
374
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
375
- });
376
-
377
- it('should parse * * * * 1-5 *', function() {
378
- var parse = parser.parse('* * * * 1-5 *');
379
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
380
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
381
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
382
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
383
- expect(parse.fields.month).to.deep.equal([1, 2, 3, 4, 5]);
384
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
385
- });
386
-
387
- it('should parse * * * * */2 *', function() {
388
- var parse = parser.parse('* * * * */2 *');
389
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
390
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
391
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
392
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
393
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 2));
394
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
395
- });
396
-
397
- it('should parse * * * * 1,2,9-11 *', function() {
398
- var parse = parser.parse('* * * * 1,2,9-11 *');
399
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
400
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
401
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
402
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
403
- expect(parse.fields.month).to.deep.equal([1,2].concat(_.range(9, 12, 1)));
404
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
405
- });
406
-
407
- it('should parse * * * * jan *', function() {
408
- var parse = parser.parse('* * * * jan *');
409
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
410
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
411
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
412
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
413
- expect(parse.fields.month).to.deep.equal([1]);
414
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
415
- });
416
-
417
- it('should parse * * * * jan,feb,mar *', function() {
418
- var parse = parser.parse('* * * * jan,feb,mar *');
419
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
420
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
421
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
422
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
423
- expect(parse.fields.month).to.deep.equal([1,2,3]);
424
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
425
- });
426
-
427
- it('should parse * * * * jan-mar *', function() {
428
- var parse = parser.parse('* * * * jan-mar *');
429
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
430
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
431
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
432
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
433
- expect(parse.fields.month).to.deep.equal([1,2,3]);
434
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
435
- });
436
-
437
- it('should parse * * * * jan-mar,oct *', function() {
438
- var parse = parser.parse('* * * * jan-mar,oct *');
439
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
440
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
441
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
442
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
443
- expect(parse.fields.month).to.deep.equal([1,2,3,10]);
444
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
445
- });
446
- });
447
-
448
- describe('day of week', function() {
449
- it('should parse * * * * * 0', function() {
450
- var parse = parser.parse('* * * * * 0');
451
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
452
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
453
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
454
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
455
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
456
- expect(parse.fields.dayOfWeek).to.deep.equal([0]);
457
- });
458
-
459
- it('should parse * * * * * 0,1,2,3,4,5', function() {
460
- var parse = parser.parse('* * * * * 0,1,2,3,4,5');
461
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
462
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
463
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
464
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
465
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
466
- expect(parse.fields.dayOfWeek).to.deep.equal([0, 1, 2, 3, 4, 5]);
467
- });
468
-
469
- it('should parse * * * * * 0-5', function() {
470
- var parse = parser.parse('* * * * * 0-5');
471
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
472
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
473
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
474
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
475
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
476
- expect(parse.fields.dayOfWeek).to.deep.equal([0, 1, 2, 3, 4, 5]);
477
- });
478
-
479
- it('should parse * * * * * */2', function() {
480
- var parse = parser.parse('* * * * * */2');
481
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
482
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
483
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
484
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
485
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
486
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 2));
487
- });
488
-
489
- it('should parse * * * * * 1,2,4-6', function() {
490
- var parse = parser.parse('* * * * * 1,2,4-6');
491
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
492
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
493
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
494
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
495
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
496
- expect(parse.fields.dayOfWeek).to.deep.equal([1, 2].concat(_.range(4, 7, 1)));
497
- });
498
-
499
- it('should parse * * * * * L');
500
-
501
- it('should parse * * * * * 2#1');
502
-
503
- it('should parse * * * * * mon', function() {
504
- var parse = parser.parse('* * * * * mon');
505
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
506
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
507
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
508
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
509
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
510
- expect(parse.fields.dayOfWeek).to.deep.equal([1]);
511
- });
512
-
513
- it('should parse * * * * * mon,tue,wed', function() {
514
- var parse = parser.parse('* * * * * mon,tue,wed');
515
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
516
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
517
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
518
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
519
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
520
- expect(parse.fields.dayOfWeek).to.deep.equal([1, 2, 3]);
521
- });
522
-
523
- it('should parse * * * * * mon-wed', function() {
524
- var parse = parser.parse('* * * * * mon-wed');
525
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
526
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
527
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
528
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
529
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
530
- expect(parse.fields.dayOfWeek).to.deep.equal([1, 2, 3]);
531
- });
532
-
533
- it('should parse * * * * * mon-wed,fri', function() {
534
- var parse = parser.parse('* * * * * mon-wed,fri');
535
- expect(parse.fields.seconds).to.deep.equal(_.range(0, 60, 1));
536
- expect(parse.fields.minutes).to.deep.equal(_.range(0, 60, 1));
537
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
538
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
539
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
540
- expect(parse.fields.dayOfWeek).to.deep.equal([1, 2, 3, 5]);
541
- });
542
- });
543
-
544
- describe('aliases', function() {
545
- it('should parse @yearly', function() {
546
- var parse = parser.parse('@yearly');
547
- expect(parse.fields.seconds).to.deep.equal([0]);
548
- expect(parse.fields.minutes).to.deep.equal([0]);
549
- expect(parse.fields.hours).to.deep.equal([0]);
550
- expect(parse.fields.dayOfMonth).to.deep.equal([1]);
551
- expect(parse.fields.month).to.deep.equal([1]);
552
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
553
- });
554
-
555
- it('should parse @YEARLY', function() {
556
- var parse = parser.parse('@YEARLY');
557
- expect(parse.fields.seconds).to.deep.equal([0]);
558
- expect(parse.fields.minutes).to.deep.equal([0]);
559
- expect(parse.fields.hours).to.deep.equal([0]);
560
- expect(parse.fields.dayOfMonth).to.deep.equal([1]);
561
- expect(parse.fields.month).to.deep.equal([1]);
562
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
563
- });
564
-
565
- it('should parse @monthly', function() {
566
- var parse = parser.parse('@monthly');
567
- expect(parse.fields.seconds).to.deep.equal([0]);
568
- expect(parse.fields.minutes).to.deep.equal([0]);
569
- expect(parse.fields.hours).to.deep.equal([0]);
570
- expect(parse.fields.dayOfMonth).to.deep.equal([1]);
571
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
572
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
573
- });
574
-
575
- it('should parse @MONTHLY', function() {
576
- var parse = parser.parse('@MONTHLY');
577
- expect(parse.fields.seconds).to.deep.equal([0]);
578
- expect(parse.fields.minutes).to.deep.equal([0]);
579
- expect(parse.fields.hours).to.deep.equal([0]);
580
- expect(parse.fields.dayOfMonth).to.deep.equal([1]);
581
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
582
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
583
- });
584
-
585
- it('should parse @weekly', function() {
586
- var parse = parser.parse('@weekly');
587
- expect(parse.fields.seconds).to.deep.equal([0]);
588
- expect(parse.fields.minutes).to.deep.equal([0]);
589
- expect(parse.fields.hours).to.deep.equal([0]);
590
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
591
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
592
- expect(parse.fields.dayOfWeek).to.deep.equal([0]);
593
- });
594
-
595
- it('should parse @WEEKLY', function() {
596
- var parse = parser.parse('@WEEKLY');
597
- expect(parse.fields.seconds).to.deep.equal([0]);
598
- expect(parse.fields.minutes).to.deep.equal([0]);
599
- expect(parse.fields.hours).to.deep.equal([0]);
600
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
601
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
602
- expect(parse.fields.dayOfWeek).to.deep.equal([0]);
603
- });
604
-
605
- it('should parse @daily', function() {
606
- var parse = parser.parse('@daily');
607
- expect(parse.fields.seconds).to.deep.equal([0]);
608
- expect(parse.fields.minutes).to.deep.equal([0]);
609
- expect(parse.fields.hours).to.deep.equal([0]);
610
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
611
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
612
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
613
- });
614
-
615
- it('should parse @DAILY', function() {
616
- var parse = parser.parse('@daily');
617
- expect(parse.fields.seconds).to.deep.equal([0]);
618
- expect(parse.fields.minutes).to.deep.equal([0]);
619
- expect(parse.fields.hours).to.deep.equal([0]);
620
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
621
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
622
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
623
- });
624
-
625
- it('should parse @hourly', function() {
626
- var parse = parser.parse('@hourly');
627
- expect(parse.fields.seconds).to.deep.equal([0]);
628
- expect(parse.fields.minutes).to.deep.equal([0]);
629
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
630
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
631
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
632
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
633
- });
634
-
635
- it('should parse @HOURLY', function() {
636
- var parse = parser.parse('@HOURLY');
637
- expect(parse.fields.seconds).to.deep.equal([0]);
638
- expect(parse.fields.minutes).to.deep.equal([0]);
639
- expect(parse.fields.hours).to.deep.equal(_.range(0, 24, 1));
640
- expect(parse.fields.dayOfMonth).to.deep.equal(_.range(1, 32, 1));
641
- expect(parse.fields.month).to.deep.equal(_.range(1, 13, 1));
642
- expect(parse.fields.dayOfWeek).to.deep.equal(_.range(0, 8, 1));
643
- });
644
-
645
- it('shouldn\'t parse @BACON', function() {
646
- expect(function() {
647
- var parse = parser.parse('@BACON');
648
- }).to.throw;
649
- });
650
- });
651
- });
652
-
653
- describe('next', function() {
654
- });
655
- });