Added tests for the JavaScript's MibewAPIInteraction class

This commit is contained in:
Dmitriy Simushev 2012-08-22 11:48:27 +00:00
parent 8a88f48d89
commit 3ec23b5ae5

View File

@ -1,5 +1,5 @@
// Testing MibewAPI class // Testing MibewAPIInteraction class
module("MibewAPI"); module('MibewAPIInteraction');
/** /**
* Represents test interaction type * Represents test interaction type
@ -7,24 +7,70 @@ module("MibewAPI");
* @constructor * @constructor
*/ */
function MibewAPITestInteraction() { function MibewAPITestInteraction() {
this.obligatoryArguments = {
'*': {
'return': {},
'references': {}
},
'foo': {
'bar': 127
}
};
this.reservedFunctionNames = [ this.reservedFunctionNames = [
'result' 'result'
]; ];
this.obligatoryArguments = [
'return',
'references'
];
this.getDefaultObligatoryArguments = function(){
return {
"return" : {},
"references" : {}
}
}
} }
MibewAPITestInteraction.prototype = new MibewAPIInteraction(); MibewAPITestInteraction.prototype = new MibewAPIInteraction();
// Tests for the getObligatoryArguments method
test('getObligatoryArguments', function(){
var interaction = new MibewAPITestInteraction();
// Arguments for all function
deepEqual(
interaction.getObligatoryArguments('some_function'),
['return', 'references'],
'Test with arguments for all functions'
);
// Arguments for specific function
deepEqual(
interaction.getObligatoryArguments('foo'),
['return', 'references', 'bar'],
'Test with arguments for specific function'
);
});
// Tests for the getObligatoryArgumentsDefaults method
test('getObligatoryArgumentsDefaults', function(){
var interaction = new MibewAPITestInteraction();
// Default values for arguments for all function
deepEqual(
interaction.getObligatoryArgumentsDefaults('some_function'),
{
'return': {},
'references': {}
},
'Test with default values for arguments for all functions'
);
// Default values for arguments for specific function
deepEqual(
interaction.getObligatoryArgumentsDefaults('foo'),
{
'return': {},
'references': {},
'bar': 127
},
'Test with default values for arguments for specific function'
);
});
// Testing MibewAPI class
module("MibewAPI");
// Tests for the class constructor // Tests for the class constructor
test("constructor", function(){ test("constructor", function(){
// Incorrect initialization // Incorrect initialization