smartjson/test/test.ts

36 lines
869 B
TypeScript
Raw Normal View History

import { tap, expect } from '@pushrocks/tapbundle';
2017-02-27 13:05:03 +00:00
import { Smartjson, foldDec } from '../ts/index';
2017-02-27 13:05:03 +00:00
class SomeClass extends Smartjson {
@foldDec() thisis: string = 'test';
2018-07-23 22:38:54 +00:00
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
tap.test('should create a Foldable extended instance', async () => {
2018-07-23 22:38:54 +00:00
mySomeClass = new SomeClass();
expect(mySomeClass).to.be.instanceof(SomeClass);
expect(mySomeClass).to.be.instanceof(Smartjson);
2018-07-23 22:38:54 +00:00
});
2017-02-27 13:05:03 +00:00
tap.test('should create a folded object', async () => {
2018-07-23 22:38:54 +00:00
let foldedObject = mySomeClass.foldToObject();
expect(foldedObject)
.property('thisis')
.to.equal('test');
2018-07-23 22:38:54 +00:00
});
2017-02-27 13:05:03 +00:00
tap.test('should enfold from object', async () => {
mySomeClass.enfoldFromObject({ thisis: 'test2' });
2018-07-23 22:38:54 +00:00
expect(mySomeClass)
.property('thisis')
.to.equal('test2');
2018-07-23 22:38:54 +00:00
});
tap.start();