Skip to content

Commit

Permalink
Merge pull request #11 from rashidkpc/master
Browse files Browse the repository at this point in the history
Fix linting and make sure tests pass UTC moment objects
  • Loading branch information
Rashid Khan committed Feb 25, 2014
2 parents 97da79c + b2f1f42 commit 816d280
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/courier/calculateIndices.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ define(function (require) {
throw new Error('Start must begin before end.');
}

if (!~['hour','day','week','year'].indexOf(interval)) {
if (!~['hour', 'day', 'week', 'year'].indexOf(interval)) {
throw new Error('Interval must be hour, day, week, or year.');
}

if (!pattern) {
throw new Error('Pattern can not be empty.');
}

var data = [];
while(start.isBefore(end)) {
var data = [];
while (start.isBefore(end)) {
start.add(interval, '1');
data.push(start.format(pattern));
}
Expand Down
18 changes: 9 additions & 9 deletions test/unit/specs/calculateIndices.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ define(function (require) {
expect(function () { calculateIndices(moment().subtract('day', 1), moment(), 'hour' ); }).to.throwError();
});
});

describe('hourly interval', function() {
beforeEach(function () {
var date = '2014-01-15 04:30:10';
this.start = moment(date).subtract('hours', 4);
this.end = moment(date);
this.start = moment.utc(date).subtract('hours', 4);
this.end = moment.utc(date);
this.interval = 'hour';
this.pattern = '[logstash-]YYYY.MM.DD.HH';
this.fixture = [
Expand All @@ -39,8 +39,8 @@ define(function (require) {
describe('daily interval', function() {
beforeEach(function () {
var date = '2014-01-15 04:30:10';
this.start = moment(date).subtract('days', 4);
this.end = moment(date);
this.start = moment.utc(date).subtract('days', 4);
this.end = moment.utc(date);
this.interval = 'day';
this.pattern = '[logstash-]YYYY.MM.DD';
this.fixture = [
Expand All @@ -59,8 +59,8 @@ define(function (require) {
describe('weekly interval', function() {
beforeEach(function () {
var date = '2014-01-15 04:30:10';
this.start = moment(date).subtract('week', 4);
this.end = moment(date);
this.start = moment.utc(date).subtract('week', 4);
this.end = moment.utc(date);
this.interval = 'week';
this.pattern = '[logstash-]YYYY.MM.DD';
this.fixture = [
Expand All @@ -79,8 +79,8 @@ define(function (require) {
describe('yearly interval', function() {
beforeEach(function () {
var date = '2014-01-15 04:30:10';
this.start = moment(date).subtract('years', 4);
this.end = moment(date);
this.start = moment.utc(date).subtract('years', 4);
this.end = moment.utc(date);
this.interval = 'year';
this.pattern = '[logstash-]YYYY.MM.DD';
this.fixture = [
Expand Down

0 comments on commit 816d280

Please sign in to comment.