Location: A review of cardiac cellular electrophysiology models @ f954e5918331 / dojo-presentation / js / dojo / dojox / rpc / tests / Wikipedia.js

Author:
David Nickerson <david.nickerson@gmail.com>
Date:
2021-09-16 00:41:19+12:00
Desc:
Updating Noble 1962 model: * Exposing the membrane potential to the top-level model; * adding SED-ML for the paced and pacemaker variants of the model. Using OpenCOR Snapshot release 2021-09-14.
Permanent Source URI:
https://models.fieldml.org/workspace/a1/rawfile/f954e59183314cd37f86c8832dc81317d01c8ec5/dojo-presentation/js/dojo/dojox/rpc/tests/Wikipedia.js

dojo.provide("dojox.rpc.tests.Wikipedia");
dojo.require("dojo.io.script");
dojo.require("dojox.rpc.Service");

dojox.rpc.tests.wikipediaService = new dojox.rpc.Service(dojo.moduleUrl("dojox.rpc.SMDLibrary", "wikipedia.smd"));

dojox.rpc.tests.wikipediaService.TEST_METHOD_TIMEOUT = 8000;

dojox.rpc.tests.wikipediaService._query = function(q){
	return function(m){
		var d = new doh.Deferred();

		if (q.parameters && q.parameters.action && q.expectedResult) {
			var wp = dojox.rpc.tests.wikipediaService.query(q.parameters);
			wp.addCallback(this, function(result){
				console.log(result);
				if (result[q.expectedResult]){
					d.callback(true);
				}else{
					d.errback(new Error("Unexpected Return Value: ", result));
				}
			});
		}

		return d;
	}
};

doh.register("dojox.rpc.tests.wikipedia", 
	[
		{
			name: "#1, Wikipedia::parse",
			timeout: dojox.rpc.tests.wikipediaService.TEST_METHOD_TIMEOUT,
			runTest: dojox.rpc.tests.wikipediaService._query({
				parameters: {
					action: "parse",
					page: "Dojo Toolkit"
				},
				expectedResult: "parse"
			})
		},
		{
			name: "#2, Wikipedia::search",
			timeout: dojox.rpc.tests.wikipediaService.TEST_METHOD_TIMEOUT,
			runTest: dojox.rpc.tests.wikipediaService._query({
				parameters: {
					action: "query",
					list: "search",
					srwhat: "text",
					srsearch: "Dojo Toolkit"
				},
				expectedResult: "query"
			})
		}
]);