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