|
| 1 | +module('transforms integration tests', { |
| 2 | + setup: function() { |
| 3 | + ajaxHash = null; |
| 4 | + App.reset(); |
| 5 | + }, |
| 6 | + teardown: function() { |
| 7 | + $.mockjaxClear(); |
| 8 | + } |
| 9 | +}); |
| 10 | + |
| 11 | +test('date attribute serializes properly', function() { |
| 12 | + stubEndpointForHttpRequest('/api/new-obituary', {}, 'POST', 201); |
| 13 | + visit('/new-obituary'); |
| 14 | + fillIn('.publish-on', '2012/08/29'); |
| 15 | + click('button.submit'); |
| 16 | + |
| 17 | + andThen(function() { |
| 18 | + equal( |
| 19 | + ajaxHash.data, |
| 20 | + '{"publish_on":"2012-08-29","time_of_death":null}' |
| 21 | + ); |
| 22 | + }); |
| 23 | +}); |
| 24 | + |
| 25 | +test('datetime attribute serializes properly', function() { |
| 26 | + stubEndpointForHttpRequest('/api/new-obituary', {}, 'POST', 201); |
| 27 | + visit('/new-obituary'); |
| 28 | + fillIn('.time-of-death', '2014-11-19T17:38:00.000Z'); |
| 29 | + click('button.submit'); |
| 30 | + |
| 31 | + andThen(function() { |
| 32 | + equal( |
| 33 | + ajaxHash.data, |
| 34 | + '{"publish_on":null,"time_of_death":"2014-11-19T17:38:00.000Z"}' |
| 35 | + ); |
| 36 | + }); |
| 37 | +}); |
| 38 | + |
| 39 | +test('date attribute deserializes properly', function() { |
| 40 | + var response = '[{"id":1,"publish_on":"2012-08-29","time_of_death":null}]'; |
| 41 | + stubEndpointForHttpRequest('/api/obituaries/', response, 'GET', 200); |
| 42 | + visit('/obituaries/'); |
| 43 | + |
| 44 | + andThen(function() { |
| 45 | + equal(find('.publish-on').text(), 'Tue Aug 28 2012 20:00:00 GMT-0400 (EDT)'); |
| 46 | + }); |
| 47 | +}); |
| 48 | + |
| 49 | +test('datetime attribute deserializes properly', function() { |
| 50 | + var response = '[{"id":1,"publish_on":null,"time_of_death":"2014-11-19T17:38:00.000Z"}]'; |
| 51 | + stubEndpointForHttpRequest('/api/obituaries/', response, 'GET', 200); |
| 52 | + visit('/obituaries/'); |
| 53 | + |
| 54 | + andThen(function() { |
| 55 | + equal(find('.time-of-death').text(), 'Wed Nov 19 2014 12:38:00 GMT-0500 (EST)'); |
| 56 | + }); |
| 57 | +}); |
0 commit comments