|
|
@ -217,5 +217,49 @@ describe("registry", () => {
|
|
|
|
registry.createTrait("DuplicateTrait", {});
|
|
|
|
registry.createTrait("DuplicateTrait", {});
|
|
|
|
}).to.throw("A trait named DuplicateTrait already exists in this registry");
|
|
|
|
}).to.throw("A trait named DuplicateTrait already exists in this registry");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it("should allow using types from different registries (as well as registry-less types) with one another", () => {
|
|
|
|
|
|
|
|
let registryOne = dm.createRegistry();
|
|
|
|
|
|
|
|
let registryTwo = dm.createRegistry();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let Item = dm.createType("Item", {
|
|
|
|
|
|
|
|
value: dm.string()
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let ItemOne = registryOne.createType("Item", {
|
|
|
|
|
|
|
|
two: registryTwo.type("Item")
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let ItemTwo = registryTwo.createType("Item", {
|
|
|
|
|
|
|
|
item: Item
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let zero = Item({
|
|
|
|
|
|
|
|
value: "foo"
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let two = ItemTwo({
|
|
|
|
|
|
|
|
item: zero
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let one = ItemOne({
|
|
|
|
|
|
|
|
two: two
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(one.two.item.value).to.equal("foo");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(() => {
|
|
|
|
|
|
|
|
ItemOne({
|
|
|
|
|
|
|
|
two: ItemOne({
|
|
|
|
|
|
|
|
two: ItemTwo({
|
|
|
|
|
|
|
|
item: Item({
|
|
|
|
|
|
|
|
value: "bar"
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}).to.throw("Expected an instance of Item, got an instance of Item instead");
|
|
|
|
|
|
|
|
/* TODO: Clarify the error message when the display name of two types is the same. */
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|