Adding unit tests.

This commit is contained in:
ahocevar
2012-08-06 23:17:15 +02:00
parent b61120d3b5
commit c64621f510
3 changed files with 174 additions and 0 deletions

65
tests/WPSClient.html Normal file
View File

@@ -0,0 +1,65 @@
<html>
<head>
<script src="OLLoader.js"></script>
<script type="text/javascript">
var client;
function test_initialize(t) {
t.plan(2);
client = new OpenLayers.WPSClient({
servers: {
local: "/geoserver/wps"
}
});
t.ok(client instanceof OpenLayers.WPSClient, 'creates an instance');
t.eq(client.servers.local.url, '/geoserver/wps', 'servers stored on instance');
}
function test_getProcess(t) {
t.plan(4);
client = new OpenLayers.WPSClient({
servers: {
local: "/geoserver/wps"
},
lazy: true
});
var process = client.getProcess('local', 'gs:splitPolygon');
t.ok(process instanceof OpenLayers.WPSProcess, 'creates a process');
t.ok(process.client === client, 'process knows about client');
t.eq(process.server, 'local', 'process created with correct server');
t.eq(process.identifier, 'gs:splitPolygon', 'process created with correct identifier');
}
function test_execute(t) {
t.plan(1);
client = new OpenLayers.WPSClient({
servers: {
local: "/geoserver/wps"
},
lazy: true
});
var log = [];
client.getProcess = function() {
return {
execute: function(options) {
log.push(options);
}
}
}
client.execute({inputs: 'a', success: 'b', scope: 'c'});
t.eq(log[0], {inputs: 'a', success: 'b', scope: 'c'}, "process executed with correct options");
}
</script>
</head>
<body>
</body>
</html>