1
0

Adding Memoize v1

This commit is contained in:
2020-03-06 13:08:45 -05:00
parent 62ab887ada
commit fa38bb6b4e
4 changed files with 43 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
import 'reflect-metadata';
import { Serde } from "src/serde";
import { Memoize } from 'src/decorators';
class MemoizeTestModel extends Serde<MemoizeTestModel> {
name: string;
@Memoize() doNameRandom(): string {
return this.name + (Math.random() * 10);
}
}
describe('@Memoize() Decorator', () => {
it('should remember...', () => {
const testModel = new MemoizeTestModel().deserialize({
name: 'test model',
});
const result1 = testModel.doNameRandom();
const result2 = testModel.doNameRandom();
expect(result1).toBe(result2);
});
});