Skip to content

Commit

Permalink
Tests (#288)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBuchholz committed Sep 14, 2018
1 parent a333164 commit d3b9053
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions test/serial/get.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"use strict";

describe("serial/get", function () {

describe("gpf.serial.getProperties", function () {

var A;

before(function () {
A = gpf.define({
$class: "A",

"[_id]": [new gpf.attributes.Serializable({
name: "id",
required: true
})],
_id: "",

"[_name]": [new gpf.attributes.Serializable({
name: "name"
})],
_name: ""
});
});

function _checkProperties (properties) {
assert(Object.keys(properties).length === 2);
assert(properties._id.name === "id");
assert(properties._name.name === "name");
}

it("lists serializable properties (on class)", function () {
_checkProperties(gpf.serial.get(A));
});

it("lists serializable properties (on instance)", function () {
_checkProperties(gpf.serial.get(new A()));
});

it("returns an empty object if no serializable attributes", function () {
var properties = gpf.serial.get(new Date());
assert(Object.keys(properties).length === 0);
});

});

});

0 comments on commit d3b9053

Please sign in to comment.