Skip to content

Commit

Permalink
Property definition and check (#281)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBuchholz committed Aug 22, 2018
1 parent 21f88b9 commit 0881022
Showing 1 changed file with 29 additions and 16 deletions.
45 changes: 29 additions & 16 deletions test/serial/property.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,38 @@ 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 () {

it("validates name", function () {
var exceptionCaught;
try {
_gpfSerialPropertyCheck({
name: "OK",
type: gpf.serial.types.string
name: "OK"
});
} catch (e) {
exceptionCaught = e;
}
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;
Expand All @@ -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);
});
});

});

}
Expand Down

0 comments on commit 0881022

Please sign in to comment.