|
|
@ -144,6 +144,62 @@ describe("registry", () => {
|
|
|
|
value: "bar42"
|
|
|
|
value: "bar42"
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}).to.throw("Value for property 'value' failed `matches` condition");
|
|
|
|
}).to.throw("Value for property 'value' failed `matches` condition");
|
|
|
|
})
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it("should work correctly for guarded maps and sets", () => {
|
|
|
|
|
|
|
|
let SomeType = registry.createType("SomeType", {
|
|
|
|
|
|
|
|
value: dm.string()
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let SomeOtherType = registry.createType("SomeOtherType", {
|
|
|
|
|
|
|
|
things: dm.setOf(registry.type("SomeType")),
|
|
|
|
|
|
|
|
thingsMap: dm.mapOf(dm.string(), registry.type("SomeType"))
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let thingOne = SomeType({
|
|
|
|
|
|
|
|
value: "one"
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let thingTwo = SomeType({
|
|
|
|
|
|
|
|
value: "two"
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let collection = SomeOtherType({
|
|
|
|
|
|
|
|
things: new Set([
|
|
|
|
|
|
|
|
thingOne,
|
|
|
|
|
|
|
|
thingTwo
|
|
|
|
|
|
|
|
]),
|
|
|
|
|
|
|
|
thingsMap: new Map([
|
|
|
|
|
|
|
|
["one", thingOne],
|
|
|
|
|
|
|
|
["two", thingTwo]
|
|
|
|
|
|
|
|
])
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(() => {
|
|
|
|
|
|
|
|
SomeOtherType({
|
|
|
|
|
|
|
|
things: new Set([
|
|
|
|
|
|
|
|
"not",
|
|
|
|
|
|
|
|
"things"
|
|
|
|
|
|
|
|
]),
|
|
|
|
|
|
|
|
thingsMap: new Map([
|
|
|
|
|
|
|
|
["one", thingOne],
|
|
|
|
|
|
|
|
["two", thingTwo]
|
|
|
|
|
|
|
|
])
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}).to.throw("Expected an instance of SomeType, got a string instead");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(() => {
|
|
|
|
|
|
|
|
SomeOtherType({
|
|
|
|
|
|
|
|
things: new Set([
|
|
|
|
|
|
|
|
thingOne,
|
|
|
|
|
|
|
|
thingTwo
|
|
|
|
|
|
|
|
]),
|
|
|
|
|
|
|
|
thingsMap: new Map([
|
|
|
|
|
|
|
|
["one", "not"],
|
|
|
|
|
|
|
|
["two", "things"]
|
|
|
|
|
|
|
|
])
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}).to.throw("Expected an instance of SomeType, got a string instead");
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|