var ArrayAssert = Y.ArrayAssert,
ObjectAssert = Y.ObjectAssert,
// -- Global Suite -------------------------------------------------------------
// -- ModelList Suite ----------------------------------------------------------
// -- ModelList: Lifecycle -----------------------------------------------------
name: 'Lifecycle',
setUp: function () {
},
tearDown: function () {
delete this.list;
},
'destructor should detach all models from the list': function () {
}
}));
// -- ModelList: Attributes and Properties -------------------------------------
name: 'Attributes & Properties',
setUp: function () {
},
tearDown: function () {
delete this.list;
Y.CustomModel && delete Y.CustomModel;
},
'ModelList instances should have an `_isYUIModelList` property': function () {
},
'ModelList instances should have a `model` property that defaults to Y.Model': function () {
},
'`model` property should be customizable on init': function () {
},
'`model` property should evaluate a string to a namespaced class on `Y`': function () {
model: 'CustomModel'
}),
list = new CustomList();
},
'`model` property should support deeply-nested names': function () {
model: 'Foo.Bar.CustomModel'
}),
list = new CustomList();
}
}));
// -- ModelList: Methods -------------------------------------------------------
name: 'Methods',
setUp: function () {
ATTRS: {
}
});
this.createList = function (modelClass) {
};
this.createModel = function (config) {
};
},
tearDown: function () {
delete this.createList;
delete this.createModel;
delete this.TestList;
delete this.TestModel;
},
'add() should add a model to the list': function () {
var list = this.createList(),
model = this.createModel(),
},
'add() should add an array of models to the list': function () {
var list = this.createList(),
},
'add() should add models in another ModelList to the list': function () {
var list = this.createList(),
otherList = this.createList(),
ArrayAssert.itemsAreSame(otherModels, list.add(otherList), 'should return an array of added models');
},
'add() should support models created in other windows': function () {
var list = this.createList(),
},
'comparator() should be undefined by default': function () {
},
'models should be added in the proper position based on the comparator': function () {
var list = this.createList();
};
},
'create() should create or update a model, then add it to the list': function () {
var list = this.createList(),
model = this.createModel();
},
'create() should call the callback if one is provided': function () {
var calls = 0,
list = this.createList();
calls += 1;
});
},
'create() should pass an error to the callback if one occurs': function () {
var calls = 0,
list = this.createList(),
model = this.createModel();
callback('Oh noes!');
};
calls += 1;
});
},
'create() should support models created in other windows': function () {
var list = this.createList(),
},
'filter() should filter the list and return an array': function () {
var list = this.createList(),
});
},
'filter() should return an empty array if the callback never returns a truthy value': function () {
var list = this.createList();
},
'filter() should return a new ModelList when options.asList is truthy': function () {
var list = this.createList(),
});
Assert.areSame(list.model, filtered.model, 'filtered list should have the same `model` property as the original list');
},
'get() should return an array of attribute values from all models in the list': function () {
var list = this.createList();
},
'get() should return a list attribute if there is one': function () {
var list = this.createList();
},
'getAsHTML() should return an array of HTML-escaped attribute values': function () {
var list = this.createList();
},
'getAsHTML() should return a list attribute if there is one': function () {
var list = this.createList();
},
'getAsURL() should return an array of URL-encoded attribute values': function () {
var list = this.createList();
},
'getAsURL() should return a list attribute if there is one': function () {
var list = this.createList();
},
'getByClientId() should look up a model by its clientId': function () {
var list = this.createList(),
},
'getById() should look up a model by its id': function () {
var list = this.createList(),
},
'getById() should work with numeric ids': function () {
var list = this.createList(),
},
'getById() should work with custom ids': function () {
idAttribute: 'customId'
}, {
ATTRS: {
}
}),
},
'invoke() should call the named method on every model in the list': function () {
var list = this.createList(),
ArrayAssert.itemsAreSame(list.toArray(), results, 'invoke should return an array of return values');
},
'item() should return the model at the specified index': function () {
var list = this.createList();
},
'load() should delegate to sync()': function () {
var calls = 0,
list = this.createList(),
opts = {};
calls += 1;
callback();
};
},
'load() should be chainable and should call the callback if one was provided': function () {
var calls = 0,
list = this.createList();
calls += 1;
}));
calls += 1;
}));
},
'load() should reset the list with the loaded items': function () {
var calls = 0,
list = this.createList();
if (action === 'read') {
callback(null, '[{"foo":"modelOne"}, {"foo":"modelTwo"}]');
}
};
calls += 1;
});
},
'load() callback should receive an error when a sync error occurs': function () {
var calls = 0,
list = this.createList();
};
calls += 1;
});
},
'map() should execute a function on every model in the list and return an array of return values': function () {
var list = this.createList(),
obj = {},
}, obj);
},
'parse() should parse a JSON string and return an object': function () {
var list = this.createList(),
},
'parse() should not try to parse non-strings': function () {
var list = this.createList(),
},
'remove() should remove a single model from the list': function () {
var list = this.createList();
},
'remove() should remove an array of models from the list': function () {
var list = this.createList(),
},
'remove() should remove models in another ModelList from the list': function () {
var list = this.createList(),
otherList = this.createList(),
ArrayAssert.itemsAreSame(otherModels, list.remove(otherList), 'should return an array of removed models');
},
'reset() should replace all models in the list': function () {
var list = this.createList(),
// Removed models should be cleanly detached.
// And we should be able to re-add them.
},
'reset() should sort the new models in the list': function () {
var list = this.createList();
};
]);
},
'reset() with no args should clear the list': function () {
var list = this.createList(),
},
'reset() should add models in another ModelList to the list': function () {
var list = this.createList(),
otherList = this.createList(),
},
'reset() should support models created in other windows': function () {
var list = this.createList(),
},
// 'set() should set a single attribute value on all models in the list': function () {
//
// },
//
// 'setAttrs() should set multiple attribute values on all models in the list': function () {
//
// },
'sort() should re-sort the list': function () {
var list = this.createList();
};
},
'sync() should just call the supplied callback by default': function () {
var calls = 0,
list = this.createList();
calls += 1;
});
},
'toArray() should return an array containing all the models in the list': function () {
var list = this.createList(),
},
'toJSON() should return an array of model hashes': function () {
var list = this.createList(),
}
}));
// -- ModelList: Events --------------------------------------------------------
name: 'Events',
setUp: function () {
ATTRS: {
}
});
this.createList = function (modelClass) {
};
this.createModel = function (config) {
};
},
tearDown: function () {
delete this.createList;
delete this.createModel;
delete this.TestList;
delete this.TestModel;
},
'`add` event should fire when a model is added': function () {
var calls = 0,
list = this.createList(),
model = this.createModel();
calls += 1;
});
calls += 1;
});
},
'`add` event should be preventable': function () {
var calls = 0,
list = this.createList();
calls += 1;
e.preventDefault();
});
});
},
'`add` event should not fire when a model is added silently': function () {
var list = this.createList();
});
},
'`change` event should bubble up from models': function () {
var calls = 0,
list = this.createList(),
calls += 1;
});
},
'`create` event should fire when a model is created': function () {
var calls = 0,
list = this.createList(),
model = this.createModel();
calls += 1;
});
});
},
'`create` event should receive options passed to the create() method': function () {
var calls = 0,
list = this.createList(),
model = this.createModel();
calls += 1;
});
},
'`error` event should bubble up from models': function () {
var calls = 0,
list = this.createList(),
callback('fail!');
}
};
calls += 1;
});
},
'`error` event should fire when a model with a duplicate clientId is added': function () {
var calls = 0,
list = this.createList(),
model = this.createModel(),
model2 = this.createModel();
calls += 1;
});
},
'`error` event should fire when a model with a duplicate id is added': function () {
var calls = 0,
list = this.createList(),
model = this.createModel(),
model2 = this.createModel(),
model3 = this.createModel();
calls += 1;
});
},
"`error` event should fire when a model that isn't in the list is removed": function () {
var calls = 0,
list = this.createList(),
model = this.createModel();
calls += 1;
});
},
"`error` event should fire when a sync layer response can't be parsed": function () {
var calls = 0,
list = this.createList(),
response = 'foo bar baz';
calls += 1;
});
},
'`load` event should fire after a successful load operation': function () {
var calls = 0,
list = this.createList();
calls += 1;
});
callback(null, '[{"foo": "bar"}]');
};
});
},
'`reset` event should fire when the list is reset or sorted': function () {
var calls = 0,
list = this.createList(),
calls += 1;
});
calls += 1;
});
};
},
'`reset` event facade should contain sorted models': function () {
var calls = 0,
list = this.createList();
};
var values = [];
calls += 1;
});
});
]);
},
'`reset` event should be preventable': function () {
var calls = 0,
list = this.createList();
calls += 1;
e.preventDefault();
});
});
},
'`reset` event should not fire when the list is reset silently': function () {
var list = this.createList();
});
},
'`reset` event should allow the caller to override the `src` property on the event facade': function () {
var calls = 0,
list = this.createList();
calls += 1;
});
},
'`remove` event should fire when a model is removed': function () {
var calls = 0,
list = this.createList(),
calls += 1;
});
calls += 1;
});
},
'`remove` event should be preventable': function () {
var calls = 0,
list = this.createList();
calls += 1;
e.preventDefault();
});
});
},
'`remove` event should not fire when a model is removed silently': function () {
var list = this.createList();
});
}
}));
}, '@VERSION@', {
});