Skip to content

Commit

Permalink
Merge pull request #175 from stefanpenner/now-use-moment-now
Browse files Browse the repository at this point in the history
Now helper uses moment.now
  • Loading branch information
jasonmit committed May 29, 2016
2 parents e91139d + 92a3cf3 commit b09c89d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion addon/helpers/now.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import moment from 'moment';
import BaseHelper from './-base';

export default BaseHelper.extend({
compute() {
this._super(...arguments);

return new Date();
return moment.now();
}
});
24 changes: 24 additions & 0 deletions tests/unit/helpers/now-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import moment from 'moment';
import hbs from 'htmlbars-inline-precompile';
import { moduleForComponent, test } from 'ember-qunit';

let originalNow;

moduleForComponent('now', {
integration: true,
beforeEach() {
moment.locale('en');
originalNow = moment.now;
},
afterEach() {
moment.now = originalNow;
}
});

test('returns the result of moment.now', function(assert) {
assert.expect(1);

moment.now = () => moment('20111031');
this.render(hbs`{{moment-format (now) 'YYYYMMDD'}}`);
assert.equal(this.$().text(), '20111031');
});

0 comments on commit b09c89d

Please sign in to comment.