|
|
|
@ -1,7 +1,10 @@
|
|
|
|
|
!function(){
|
|
|
|
|
'use strict';
|
|
|
|
|
var $ = require('jquery');
|
|
|
|
|
var Backbone = require('backbone');
|
|
|
|
|
var _ = require('underscore');
|
|
|
|
|
require('../backbone-model-file-upload');
|
|
|
|
|
var Blob = require('blob');
|
|
|
|
|
|
|
|
|
|
describe('Testing Backbone Model Plugin', function(){
|
|
|
|
|
describe('Testing Backbone Model Plugin', function () {
|
|
|
|
|
|
|
|
|
|
Backbone.$.ajaxSetup({
|
|
|
|
|
headers: {
|
|
|
|
@ -19,7 +22,7 @@
|
|
|
|
|
var fileModel;
|
|
|
|
|
var simulatedFileObj;
|
|
|
|
|
|
|
|
|
|
beforeEach(function(){
|
|
|
|
|
beforeEach(function () {
|
|
|
|
|
|
|
|
|
|
simulatedFileObj = new Blob(['<strong>Hello World</strong>'], {type : 'text/html'});
|
|
|
|
|
|
|
|
|
@ -41,7 +44,7 @@
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should detect the file(blob) save successfully', function(done){
|
|
|
|
|
it('should detect the file(blob) save successfully', function (done) {
|
|
|
|
|
|
|
|
|
|
// Arrange
|
|
|
|
|
fileModel.set({fileAttachment: simulatedFileObj});
|
|
|
|
@ -66,7 +69,7 @@
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it ('should be able to be saved in as an argument of "save" as object', function(done){
|
|
|
|
|
it ('should be able to be saved in as an argument of "save" as object', function (done) {
|
|
|
|
|
|
|
|
|
|
// Listen
|
|
|
|
|
fileModel.on('sync', function(model){
|
|
|
|
@ -88,7 +91,7 @@
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it ('should be able to be saved in as an argument of "save" as key/value argument', function(done){
|
|
|
|
|
it ('should be able to be saved in as an argument of "save" as key/value argument', function (done) {
|
|
|
|
|
|
|
|
|
|
// Listen
|
|
|
|
|
fileModel.on('sync', function(model){
|
|
|
|
@ -109,7 +112,7 @@
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it ('should be able to have "wait" and "validate" option', function(done){
|
|
|
|
|
it ('should be able to have "wait" and "validate" option', function (done) {
|
|
|
|
|
|
|
|
|
|
// Listen
|
|
|
|
|
fileModel.on('sync', function(model){
|
|
|
|
@ -130,7 +133,7 @@
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should still have the option to save normally by setting it and save(null)', function(done){
|
|
|
|
|
it('should still have the option to save normally by setting it and save(null)', function (done) {
|
|
|
|
|
|
|
|
|
|
// Listen
|
|
|
|
|
fileModel.on('sync', function(model){
|
|
|
|
@ -149,7 +152,7 @@
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should still have the option to save normally by save("from","yes")', function(done){
|
|
|
|
|
it('should still have the option to save normally by save("from","yes")', function (done) {
|
|
|
|
|
|
|
|
|
|
// Listen
|
|
|
|
|
fileModel.on('sync', function(model){
|
|
|
|
@ -167,7 +170,7 @@
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should still have the option to save normally by save({from: "yes"})', function(done){
|
|
|
|
|
it('should still have the option to save normally by save({from: "yes"})', function (done) {
|
|
|
|
|
|
|
|
|
|
// Listen
|
|
|
|
|
fileModel.on('sync', function(model){
|
|
|
|
@ -185,7 +188,7 @@
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should still silent true with file', function(done){
|
|
|
|
|
it('should still silent true with file', function (done) {
|
|
|
|
|
|
|
|
|
|
var changed = false;
|
|
|
|
|
|
|
|
|
@ -214,7 +217,7 @@
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should still silent true without file', function(done){
|
|
|
|
|
it('should still silent true without file', function (done) {
|
|
|
|
|
|
|
|
|
|
var changed = false;
|
|
|
|
|
|
|
|
|
@ -240,7 +243,7 @@
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should flatten correctly using a bracket notation', function(){
|
|
|
|
|
it('should flatten correctly using a bracket notation', function () {
|
|
|
|
|
|
|
|
|
|
// Arrange
|
|
|
|
|
var expected = {
|
|
|
|
@ -261,7 +264,7 @@
|
|
|
|
|
expect(flattened["nestedObject[nestier[nestiest[2]]]"]).toBe("three");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should unflatten correctly using internal "unflatten" function', function(){
|
|
|
|
|
it('should unflatten correctly using internal "unflatten" function', function () {
|
|
|
|
|
|
|
|
|
|
var flattened = fileModel._flatten(fileModel.toJSON()),
|
|
|
|
|
unflattened = fileModel._unflatten(flattened);
|
|
|
|
@ -291,7 +294,5 @@
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}();
|