diff --git a/test/serial/property.js b/test/serial/property.js index be7937ff..b2da030a 100644 --- a/test/serial/property.js +++ b/test/serial/property.js @@ -4,7 +4,17 @@ describe("serial/property", function () { if (gpf.internals) { - var _gpfSerialPropertyCheck = gpf.internals._gpfSerialPropertyCheck; + var _gpfSerialPropertyCheck = gpf.internals._gpfSerialPropertyCheck, + values = [ + "", + 0, + 1, + {}, + new Date(), + true, + false, + "123" + ]; describe("_gpfSerialPropertyCheck", function () { @@ -12,8 +22,7 @@ describe("serial/property", function () { var exceptionCaught; try { _gpfSerialPropertyCheck({ - name: "OK", - type: gpf.serial.types.string + name: "OK" }); } catch (e) { exceptionCaught = e; @@ -21,23 +30,12 @@ describe("serial/property", function () { assert(!exceptionCaught); }); - [ - undefined, - 0, - 1, - {}, - new Date(), - true, - false, - "", - "123" - ].forEach(function (invalidName) { + [undefined].concat(values).forEach(function (invalidName) { it("rejects invalid names (" + JSON.stringify(invalidName) + ")", function () { var exceptionCaught; try { _gpfSerialPropertyCheck({ - name: invalidName, - type: gpf.serial.types.string + name: invalidName }); } catch (e) { exceptionCaught = e; @@ -46,6 +44,21 @@ describe("serial/property", function () { }); }); + values.forEach(function (invalidType) { + it("rejects invalid types (" + JSON.stringify(invalidType) + ")", function () { + var exceptionCaught; + try { + _gpfSerialPropertyCheck({ + name: "OK", + type: invalidType + }); + } catch (e) { + exceptionCaught = e; + } + assert(exceptionCaught instanceof gpf.Error.InvalidSerialType); + }); + }); + }); }