Skip to content
Snippets Groups Projects
Commit c639fc21 authored by totten's avatar totten
Browse files

HR-226 - CRM.Backbone.extendCollection - Unit test for "crmCriteriaModel"

parent a449b17d
No related branches found
No related tags found
No related merge requests found
...@@ -195,7 +195,7 @@ asyncTest("update (error)", function() { ...@@ -195,7 +195,7 @@ asyncTest("update (error)", function() {
module('collection - read'); module('collection - read');
asyncTest("fetch by contact_type (1+ results)", function() { asyncTest("fetch by contact_type (passive criteria, 1+ results)", function() {
var c = new ContactCollection([], { var c = new ContactCollection([], {
crmCriteria: { crmCriteria: {
contact_type: 'Organization' contact_type: 'Organization'
...@@ -214,6 +214,55 @@ asyncTest("fetch by contact_type (1+ results)", function() { ...@@ -214,6 +214,55 @@ asyncTest("fetch by contact_type (1+ results)", function() {
}); });
}); });
asyncTest("fetch by contact_type (active criteria, 1+ results)", function() {
var criteria = new Backbone.Model({
contact_type: 'Organization'
});
var c = new ContactCollection([], {
crmCriteriaModel: criteria
});
c.fetch({
error: onUnexpectedError,
success: function() {
ok(c.models.length > 0, "Expected at least one contact");
c.each(function(model) {
equal(model.get('contact_type'), 'Organization', 'Expected contact with type organization');
ok(model.get('display_name') != '', 'Expected contact with valid name');
});
start();
}
});
});
asyncTest("fetch by contact_type (active criteria revision, 1+ results)", function() {
var criteria = new Backbone.Model({
contact_type: 'Household'
});
var c = new ContactCollection([], {
crmCriteriaModel: criteria
});
c.fetch({
error: onUnexpectedError,
success: function() {
ok(c.models.length > 0, "Expected at least one contact");
c.each(function(model) {
equal(model.get('contact_type'), 'Household', 'Expected contact with type household');
ok(model.get('display_name') != '', 'Expected contact with valid name');
});
criteria.set('contact_type', 'Organization');
_.delay(function() {
ok(c.models.length > 0, "Expected at least one contact");
c.each(function(model) {
equal(model.get('contact_type'), 'Organization', 'Expected contact with type organization');
ok(model.get('display_name') != '', 'Expected contact with valid name');
});
start();
}, 1000);
}
});
});
asyncTest("fetch by crazy name (0 results)", function() { asyncTest("fetch by crazy name (0 results)", function() {
var c = new ContactCollection([], { var c = new ContactCollection([], {
crmCriteria: { crmCriteria: {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment