| 1 | /* ------------ Test cases ------------ */ |
| 2 | module('api single'); |
| 3 | |
| 4 | asyncTest("simple api call", function() { |
| 5 | CRM.api3('contact', 'get').done(function(result) { |
| 6 | equal(result.is_error, 0, 'contact get'); |
| 7 | start(); |
| 8 | }); |
| 9 | }); |
| 10 | |
| 11 | module('api multiple'); |
| 12 | |
| 13 | asyncTest("array api calls", function() { |
| 14 | var params = [ |
| 15 | ['email', 'get', {email: '@'}], |
| 16 | ['phone', 'get', {phone: '123'}] |
| 17 | ]; |
| 18 | CRM.api3(params).done(function(result) { |
| 19 | equal(result[0].is_error, 0, 'email get'); |
| 20 | equal(result[1].is_error, 0, 'phone get'); |
| 21 | start(); |
| 22 | }); |
| 23 | }); |
| 24 | |
| 25 | asyncTest("named api calls", function() { |
| 26 | var params = { |
| 27 | one: ['email', 'getoptions', {field: 'location_type_id'}], |
| 28 | two: ['phone', 'getoptions', {field: 'phone_type_id', sequential: 1}], |
| 29 | three: ['phone', 'get'] |
| 30 | }; |
| 31 | CRM.api3(params).done(function(result) { |
| 32 | ok(result.one.count > 0, 'email getoptions'); |
| 33 | ok(result.two.count > 0, 'phone getoptions'); |
| 34 | ok(result.three.count > 0, 'phone get'); |
| 35 | start(); |
| 36 | }); |
| 37 | }); |