Skip to content

Commit

Permalink
Test stubbed attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
Stepan Stolyarov committed Dec 14, 2015
1 parent f11ba27 commit b6f074d
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion tests/unit/transforms/attachment-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ let testSerializedData = {
'test.txt': {
content_type: 'text/plain',
data: 'hello world!'
},
'stub.json': {
stub: true,
content_type: 'application/json'
}
};

Expand All @@ -14,6 +18,11 @@ let testDeserializedData = [
name: 'test.txt',
content_type: 'text/plain',
data: 'hello world!'
}),
Ember.Object.create({
name: 'stub.json',
content_type: 'application/json',
stub: true
})
];

Expand All @@ -25,10 +34,15 @@ test('it serializes an attachment', function(assert) {
assert.equal(transform.serialize(undefined), null);

let serializedData = transform.serialize(testDeserializedData);
let name = testDeserializedData[0].name;
let name = testDeserializedData[0].get('name');

assert.equal(serializedData[name].content_type, testSerializedData[name].content_type);
assert.equal(serializedData[name].data, testSerializedData[name].data);

let stub = testDeserializedData[1].get('name');

assert.equal(serializedData[stub].content_type, testSerializedData[stub].content_type);
assert.equal(serializedData[stub].stub, true);
});

test('it deserializes an attachment', function(assert) {
Expand All @@ -41,4 +55,8 @@ test('it deserializes an attachment', function(assert) {
assert.equal(deserializedData[0].get('name'), testDeserializedData[0].get('name'));
assert.equal(deserializedData[0].get('content_type'), testDeserializedData[0].get('content_type'));
assert.equal(deserializedData[0].get('data'), testDeserializedData[0].get('data'));

assert.equal(deserializedData[1].get('name'), testDeserializedData[1].get('name'));
assert.equal(deserializedData[1].get('content_type'), testDeserializedData[1].get('content_type'));
assert.equal(deserializedData[1].get('stub'), true);
});

0 comments on commit b6f074d

Please sign in to comment.