Last change
on this file since 256 was
256,
checked in by hendrikvanantwerpen, 13 years ago
|
Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).
|
File size:
1.4 KB
|
Line | |
---|
1 | dojo.provide("dojox.rpc.tests.Wikipedia"); |
---|
2 | dojo.require("dojo.io.script"); |
---|
3 | dojo.require("dojox.rpc.Service"); |
---|
4 | |
---|
5 | dojox.rpc.tests.wikipediaService = new dojox.rpc.Service(dojo.moduleUrl("dojox.rpc.SMDLibrary", "wikipedia.smd")); |
---|
6 | |
---|
7 | dojox.rpc.tests.wikipediaService.TEST_METHOD_TIMEOUT = 8000; |
---|
8 | |
---|
9 | dojox.rpc.tests.wikipediaService._query = function(q){ |
---|
10 | return function(m){ |
---|
11 | var d = new doh.Deferred(); |
---|
12 | |
---|
13 | if (q.parameters && q.parameters.action && q.expectedResult) { |
---|
14 | var wp = dojox.rpc.tests.wikipediaService.query(q.parameters); |
---|
15 | wp.addCallback(this, function(result){ |
---|
16 | console.log(result); |
---|
17 | if (result[q.expectedResult]){ |
---|
18 | d.callback(true); |
---|
19 | }else{ |
---|
20 | d.errback(new Error("Unexpected Return Value: ", result)); |
---|
21 | } |
---|
22 | }); |
---|
23 | } |
---|
24 | |
---|
25 | return d; |
---|
26 | } |
---|
27 | }; |
---|
28 | |
---|
29 | doh.register("dojox.rpc.tests.wikipedia", |
---|
30 | [ |
---|
31 | { |
---|
32 | name: "#1, Wikipedia::parse", |
---|
33 | timeout: dojox.rpc.tests.wikipediaService.TEST_METHOD_TIMEOUT, |
---|
34 | runTest: dojox.rpc.tests.wikipediaService._query({ |
---|
35 | parameters: { |
---|
36 | action: "parse", |
---|
37 | page: "Dojo Toolkit" |
---|
38 | }, |
---|
39 | expectedResult: "parse" |
---|
40 | }) |
---|
41 | }, |
---|
42 | { |
---|
43 | name: "#2, Wikipedia::search", |
---|
44 | timeout: dojox.rpc.tests.wikipediaService.TEST_METHOD_TIMEOUT, |
---|
45 | runTest: dojox.rpc.tests.wikipediaService._query({ |
---|
46 | parameters: { |
---|
47 | action: "query", |
---|
48 | list: "search", |
---|
49 | srwhat: "text", |
---|
50 | srsearch: "Dojo Toolkit" |
---|
51 | }, |
---|
52 | expectedResult: "query" |
---|
53 | }) |
---|
54 | } |
---|
55 | ]); |
---|
Note: See
TracBrowser
for help on using the repository browser.