smartjson/test/test.ts

36 lines
865 B
TypeScript
Raw Normal View History

2018-07-23 22:38:54 +00:00
import { tap, expect } from "@pushrocks/tapbundle";
2017-02-27 13:05:03 +00:00
2018-09-05 22:11:46 +00:00
import { Foldable, foldDec } from "../ts/index";
2017-02-27 13:05:03 +00:00
class SomeClass extends Foldable {
2018-07-23 22:38:54 +00:00
@foldDec() thisis: string = "test";
constructor() {
super();
console.log(this.saveableProperties);
2017-02-27 13:05:03 +00:00
}
}
2018-07-23 22:38:54 +00:00
let mySomeClass: SomeClass;
2017-02-27 13:05:03 +00:00
2018-07-23 22:38:54 +00:00
tap.test("should create a Foldable extended instance", async () => {
mySomeClass = new SomeClass();
expect(mySomeClass).to.be.instanceof(SomeClass);
expect(mySomeClass).to.be.instanceof(Foldable);
});
2017-02-27 13:05:03 +00:00
2018-07-23 22:38:54 +00:00
tap.test("should create a folded object", async () => {
let foldedObject = mySomeClass.foldToObject();
expect(foldedObject)
.property("thisis")
.to.equal("test");
});
2017-02-27 13:05:03 +00:00
2018-07-23 22:38:54 +00:00
tap.test("should enfold from object", async () => {
mySomeClass.enfoldFromObject({ thisis: "test2" });
expect(mySomeClass)
.property("thisis")
.to.equal("test2");
});
tap.start()