diff --git a/test/serial/property.js b/test/serial/property.js index b2da030a..89b4583a 100644 --- a/test/serial/property.js +++ b/test/serial/property.js @@ -18,46 +18,64 @@ describe("serial/property", function () { describe("_gpfSerialPropertyCheck", function () { - it("validates name", function () { - var exceptionCaught; - try { - _gpfSerialPropertyCheck({ - name: "OK" - }); - } catch (e) { - exceptionCaught = e; - } - assert(!exceptionCaught); + it("validates name and default properties", function () { + var property = _gpfSerialPropertyCheck({ + name: "OK" + }); + assert(property.type === gpf.serial.types.string); + assert(property.required === false); }); - [undefined].concat(values).forEach(function (invalidName) { - it("rejects invalid names (" + JSON.stringify(invalidName) + ")", function () { - var exceptionCaught; - try { - _gpfSerialPropertyCheck({ - name: invalidName - }); - } catch (e) { - exceptionCaught = e; - } - assert(exceptionCaught instanceof gpf.Error.InvalidSerialName); + values + .concat(undefined) + .forEach(function (invalidName) { + it("rejects invalid 'name' (" + JSON.stringify(invalidName) + ")", function () { + var exceptionCaught; + try { + _gpfSerialPropertyCheck({ + name: invalidName + }); + } catch (e) { + exceptionCaught = e; + } + assert(exceptionCaught instanceof gpf.Error.InvalidSerialName); + }); }); - }); - 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); + values + .forEach(function (invalidType) { + it("rejects invalid 'type' (" + JSON.stringify(invalidType) + ")", function () { + var exceptionCaught; + try { + _gpfSerialPropertyCheck({ + name: "OK", + type: invalidType + }); + } catch (e) { + exceptionCaught = e; + } + assert(exceptionCaught instanceof gpf.Error.InvalidSerialType); + }); + }); + + values + .filter(function (value) { + return "boolean" !== typeof value; + }) + .forEach(function (invalidRequired) { + it("rejects invalid 'required' (" + JSON.stringify(invalidRequired) + ")", function () { + var exceptionCaught; + try { + _gpfSerialPropertyCheck({ + name: "OK", + required: invalidRequired + }); + } catch (e) { + exceptionCaught = e; + } + assert(exceptionCaught instanceof gpf.Error.InvalidSerialRequired); + }); }); - }); });