From cf822220d8dd5c7e25a4c2e9dd8a0c6d32d0a8cf Mon Sep 17 00:00:00 2001 From: homeslicesolutions Date: Sat, 30 Aug 2014 12:17:39 -0700 Subject: [PATCH] Added some test around {silent: true} --- tests/backbone-model-file-upload.spec.js | 52 ++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tests/backbone-model-file-upload.spec.js b/tests/backbone-model-file-upload.spec.js index f9c0ea4..16f5552 100644 --- a/tests/backbone-model-file-upload.spec.js +++ b/tests/backbone-model-file-upload.spec.js @@ -156,6 +156,58 @@ }); + it('should still silent true with file', function(done){ + + var changed = false; + + // Listen + fileModel.on('sync', function(model){ + + // Assert + expect(model.get('fileAttachment').data).toBe('data:text/html;base64,PHN0cm9uZz5IZWxsbyBXb3JsZDwvc3Ryb25nPg=='); + + setTimeout(function(){ + expect(changed).not.toBeTruthy(); + done(); + },500); + + }); + + fileModel.on('change', function(){ + changed = true; + }) + + // Act + fileModel.save({fileAttachment: simulatedFileObj}, {silent: true}); + + }); + + it('should still silent true without file', function(done){ + + var changed = false; + + // Listen + fileModel.on('sync', function(model){ + + // Assert + expect(model.get('from')).toBe('yes'); + + setTimeout(function(){ + expect(changed).not.toBeTruthy(); + done(); + },500); + + }); + + fileModel.on('change', function(){ + changed = true; + }) + + // Act + fileModel.save({from: "yes"}, {silent: true}); + + }); + }); }(); \ No newline at end of file