Slightly more sensible instance naming in registry tests

master
Sven Slootweg 6 years ago
parent 0d9e9c83c5
commit 2e311812be

@ -31,26 +31,26 @@ describe("registry", () => {
describe("registry usage", () => {
it("should work correctly for types", () => {
let Person = registry.createType("Person", {
let SimplePerson = registry.createType("SimplePerson", {
name: dm.string(),
favouriteGift: registry.type("Gift").optional()
favouriteGift: registry.type("SimpleGift").optional()
});
let Gift = registry.createType("Gift", {
let SimpleGift = registry.createType("SimpleGift", {
description: dm.string(),
from: registry.type("Person"),
to: registry.type("Person")
from: registry.type("SimplePerson"),
to: registry.type("SimplePerson")
});
let joe = Person({
let joe = SimplePerson({
name: "Joe"
});
let jane = Person({
let jane = SimplePerson({
name: "Jane"
});
let flowers = Gift({
let flowers = SimpleGift({
description: "Flowers",
from: jane,
to: joe
@ -64,44 +64,44 @@ describe("registry", () => {
expect(() => {
jane.favouriteGift = "not a gift";
}).to.throw("Expected an instance of Gift, got a string instead");
}).to.throw("Expected an instance of SimpleGift, got a string instead");
expect(() => {
flowers.to = "not a person";
}).to.throw("Expected an instance of Person, got a string instead");
}).to.throw("Expected an instance of SimplePerson, got a string instead");
expect(() => {
flowers.to = flowers;
}).to.throw("Expected an instance of Person, got an instance of Gift instead");
}).to.throw("Expected an instance of SimplePerson, got an instance of SimpleGift instead");
});
it("should work correctly for traits", () => {
let Givable = registry.createTrait("Givable", {
from: registry.type("AlsoPerson"),
to: registry.type("AlsoPerson")
from: registry.type("Person"),
to: registry.type("Person")
});
let AlsoPerson = registry.createType("AlsoPerson", {
let Person = registry.createType("Person", {
name: dm.string(),
favouriteGift: registry.trait("Givable").optional()
});
let AlsoGift = registry.createType("AlsoGift", {
let Gift = registry.createType("Gift", {
description: dm.string()
}).implements(Givable, {
from: dm.slot(),
to: dm.slot()
});
let joe = AlsoPerson({
let joe = Person({
name: "Joe"
});
let jane = AlsoPerson({
let jane = Person({
name: "Jane"
});
let flowers = AlsoGift({
let flowers = Gift({
description: "Flowers",
from: jane,
to: joe
@ -119,11 +119,11 @@ describe("registry", () => {
expect(() => {
flowers.to = "not a person";
}).to.throw("Expected an instance of AlsoPerson, got a string instead");
}).to.throw("Expected an instance of Person, got a string instead");
expect(() => {
flowers.to = flowers;
}).to.throw("Expected an instance of AlsoPerson, got an instance of AlsoGift instead");
}).to.throw("Expected an instance of Person, got an instance of Gift instead");
});
it("should work correctly for type aliases", () => {

Loading…
Cancel
Save