smartjson/test/test.ts

36 lines
889 B
TypeScript
Raw Permalink 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 () => {
2020-10-05 11:13:17 +00:00
const mySomeClass2 = SomeClass.enfoldFromObject({ thisis: 'test2' });
expect(mySomeClass2)
.property('thisis')
.to.equal('test2');
2018-07-23 22:38:54 +00:00
});
tap.start();