Skip to content

Commit

Permalink
test #70: Add tests to demonstrate class-level decorator failures for…
Browse files Browse the repository at this point in the history
… Transform
  • Loading branch information
notheotherben committed Mar 27, 2017
1 parent 54bc543 commit f5a7268
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions test/Decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,18 +164,36 @@ describe("Decorators", () => {
});

describe("Transform", () => {
it("should not remove existing entries in the transforms object", () => {
chai.expect(Test.transforms).to.exist.and.have.property("_id").with.property("fromDB").which.is.a("function");
chai.expect(Test.transforms).to.exist.and.have.property("_id").with.property("toDB").which.is.a("function");
});
describe("on a property", () => {
it("should not remove existing entries in the transforms object", () => {
chai.expect(Test.transforms).to.exist.and.have.property("_id").with.property("fromDB").which.is.a("function");
chai.expect(Test.transforms).to.exist.and.have.property("_id").with.property("toDB").which.is.a("function");
});

it("should populate the constructor's transforms object", () => {
chai.expect(Test.transforms).to.exist.and.have.property("email").with.property("fromDB").which.is.a("function");
chai.expect(Test.transforms).to.exist.and.have.property("email").with.property("toDB").which.is.a("function");
});
it("should populate the constructor's transforms object", () => {
chai.expect(Test.transforms).to.exist.and.have.property("email").with.property("fromDB").which.is.a("function");
chai.expect(Test.transforms).to.exist.and.have.property("email").with.property("toDB").which.is.a("function");
});

it("should not pollute the parent's transforms object", () => {
chai.expect(Iridium.Instance.transforms).to.exist.and.not.have.property("email");
});
it("should not pollute the parent's transforms object", () => {
chai.expect(Iridium.Instance.transforms).to.exist.and.not.have.property("email");
});
});

describe("on a class", () => {
it("should not remove existing entries in the transforms object", () => {
chai.expect(Test.transforms).to.exist.and.have.property("_id").with.property("fromDB").which.is.a("function");
chai.expect(Test.transforms).to.exist.and.have.property("_id").with.property("toDB").which.is.a("function");
});

it("should populate the constructor's transforms object", () => {
chai.expect(Test.transforms).to.exist.and.have.property("$document").with.property("fromDB").which.is.a("function");
chai.expect(Test.transforms).to.exist.and.have.property("$document").with.property("toDB").which.is.a("function");
});

it("should not pollute the parent's transforms object", () => {
chai.expect(Iridium.Instance.transforms).to.exist.and.not.have.property("$document");
});
});
});
});

0 comments on commit f5a7268

Please sign in to comment.