Added test for array of files. Also added JSON.stringify around the flatten call in the log call at the end of the unflatten test

master
Josiah Baldwin 9 years ago
parent 86142c6af8
commit 34dbcf37a6

@ -18,10 +18,12 @@
var fileModel;
var simulatedFileObj;
var simulatedFileObj2;
beforeEach(function(){
simulatedFileObj = new Blob(['<strong>Hello World</strong>'], {type : 'text/html'});
simulatedFileObj2 = new Blob(['<strong>Hello Again, World</strong>'], {type : 'text/html'});
fileModel = new File({
from: 'sample@email.com',
@ -92,7 +94,6 @@
// Listen
fileModel.on('sync', function(model){
// Assert
expect(model.get('from')).toBe('sample@email.com');
// Assert Blob (phantomJS can't do Blobs so just test minimal attributes)
@ -109,6 +110,28 @@
});
it ('should be able to save an array of multiple file objects', function(done){
// Listen
fileModel.on('sync', function(model){
// Assert
expect(model.get('from')).toBe('sample@email.com');
// Assert Blob (phantomJS can't do Blobs so just test minimal attributes)
expect(model.get('fileAttachment')[0].size).toBe(28);
expect(model.get('fileAttachment')[0].type).toBe('text/html');
//expect(model.get('fileAttachment')[0].data).toBe('data:text/html;base64,PHN0cm9uZz5IZWxsbyBXb3JsZDwvc3Ryb25nPg==')
expect(model.get('fileAttachment')[1].size).toBe(35);
expect(model.get('fileAttachment')[1].type).toBe('text/html');
//expect(model.get('fileAttachment')[1].data).toBe('data:text/html;base64,PHN0cm9uZz5IZWxsbyBBZ2FpbiwgV29ybGQ8L3N0cm9uZz4K=')
done();
});
// Act
fileModel.save('fileAttachment', [simulatedFileObj, simulatedFileObj2], {formData: true});
});
it ('should be able to have "wait" and "validate" option', function(done){
// Listen
@ -268,7 +291,7 @@
expect(_.isEqual(unflattened, fileModel.toJSON())).toBeTruthy();
console.log(fileModel._flatten({
console.log(JSON.stringify(fileModel._flatten({
'family': 'The Smiths',
'grandpa': {
'name': 'Ole Joe Smith',
@ -287,7 +310,7 @@
}
]
}
}));
})));
});

Loading…
Cancel
Save