Skip to content

Commit

Permalink
Add tests for the datetransform with a timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
bmac committed May 24, 2016
1 parent dcafebf commit 17b1f1c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
18 changes: 9 additions & 9 deletions addon/-private/ext/date.js
Expand Up @@ -47,12 +47,12 @@ export const parseDate = function (date) {
Ember.Date.parse = function (date) {
// throw deprecation
deprecate(`Ember.Date.parse is deprecated because Safari 5-, IE8-, and
Firefox 3.6- are no longer supported (see
https://github.com/csnover/js-iso8601 for the history of this issue).
Please use Date.parse instead`, false, {
id: 'ds.ember.date.parse-deprecate',
until: '3.0.0'
});
Firefox 3.6- are no longer supported (see
https://github.com/csnover/js-iso8601 for the history of this issue).
Please use Date.parse instead`, false, {
id: 'ds.ember.date.parse-deprecate',
until: '3.0.0'
});

return parseDate(date);
};
Expand All @@ -70,8 +70,8 @@ ENV = {
}
}
`, false, {
id: 'ds.date.parse-deprecate',
until: '3.0.0'
});
id: 'ds.date.parse-deprecate',
until: '3.0.0'
});
Date.parse = parseDate;
}
1 change: 0 additions & 1 deletion addon/-private/transforms/date.js
@@ -1,4 +1,3 @@
import Ember from 'ember';
import { parseDate } from "ember-data/-private/ext/date";

/**
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/transform/date-test.js
Expand Up @@ -39,6 +39,17 @@ test("#deserialize", function(assert) {
assert.equal(transform.deserialize(undefined), null);
});

test("#deserialize with different offset formats", function(assert) {
var transform = new DS.DateTransform();
var dateString = '2003-05-24T23:00:00.000+0000';
var dateStringColon = '2013-03-15T23:22:00.000+00:00';
var dateStringShortOffset = '2016-12-02T17:30:00.000+00';

assert.equal(transform.deserialize(dateString).getTime(), 1053817200000);
assert.equal(transform.deserialize(dateStringShortOffset).getTime(), 1480699800000);
assert.equal(transform.deserialize(dateStringColon).getTime(), 1363389720000);
});

testInDebug('Ember.Date.parse has been deprecated', function(assert) {
run(function() {
assert.expectDeprecation(function() {
Expand Down

0 comments on commit 17b1f1c

Please sign in to comment.