From 9c380e386b55674caa5a873bb27aed83d66bcd1a Mon Sep 17 00:00:00 2001 From: Cesare Cameroni Date: Fri, 29 Mar 2013 14:40:06 +0100 Subject: [PATCH] Prop message validation jasmine test Jira-issue: WP-349 --- .../util/test/jasmine/schema_test.spec.js | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/webinos/core/util/test/jasmine/schema_test.spec.js b/webinos/core/util/test/jasmine/schema_test.spec.js index 01bedde6..ae8cc8da 100644 --- a/webinos/core/util/test/jasmine/schema_test.spec.js +++ b/webinos/core/util/test/jasmine/schema_test.spec.js @@ -36,3 +36,50 @@ describe('Generic message check', function() { expect(validation.checkSchema(wrong_generic_msg)).toEqual(true); }); }); + +describe('Prop message check', function() { + + // Prop message example + var prop_msg = { + type : 'Prop', + from : 'fromString', + to : 'toString', + id : 'idString', + payload : {} + }; + + it('Recognized Prop message', function() { + expect(validation.checkSchema(prop_msg)).toEqual(false); + }); + + // wrong Prop message examples + var wrong_prop_msg = []; + wrong_prop_msg[0] = { + type : 'Prop', + from : 'fromString', + to : 'toString', + //id : 'idString', // required field is missing + payload : {} + }; + wrong_prop_msg[1] = { + type : 'Prop', + from : 'fromString', + to : 'toString', + id : 'idString', + additional_field : 'fieldString', // not allowed field + payload : {} + }; + wrong_prop_msg[2] = { + type : 'Prop', + from : 'fromString', + to : 'toString', + id : 5, // wrong type + payload : {} + }; + + it('Unrecognized Prop messages', function() { + for (var i = 0; i < wrong_prop_msg.length; i++) { + expect(validation.checkSchema(wrong_prop_msg[i])).toEqual(true); + } + }); +});