-
-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #175 from stefanpenner/now-use-moment-now
Now helper uses moment.now
- Loading branch information
Showing
2 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}); |