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) { | |
f07cebc3 | 7 | equal(result.is_error, 0, 'contact get'); |
0fe377f6 CW |
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) { | |
f07cebc3 CW |
20 | equal(result[0].is_error, 0, 'email get'); |
21 | equal(result[1].is_error, 0, 'phone get'); | |
0fe377f6 CW |
22 | start(); |
23 | }); | |
24 | }); | |
25 | ||
26 | asyncTest("named api calls", function() { | |
27 | var params = { | |
28 | one: ['email', 'getoptions', {field: 'location_type_id'}], | |
f07cebc3 CW |
29 | two: ['phone', 'getoptions', {field: 'phone_type_id', sequential: 1}], |
30 | three: ['phone', 'get'] | |
0fe377f6 CW |
31 | }; |
32 | CRM.api3(params).done(function(result) { | |
f07cebc3 CW |
33 | ok(result.one.count > 0, 'email getoptions'); |
34 | ok(result.two.count > 0, 'phone getoptions'); | |
35 | ok(result.three.count > 0, 'phone get'); | |
0fe377f6 CW |
36 | start(); |
37 | }); | |
38 | }); |