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

Loading…
Cancel
Save