hexo/node_modules/moize/__tests__/isMoized.ts

23 lines
626 B
TypeScript
Raw Normal View History

2023-10-03 11:14:36 +08:00
import moize from '../src';
const method = jest.fn(function (one: string, two: string) {
return { one, two };
});
describe('moize.isMoized', () => {
it('should validate if the function passed is moized', () => {
const memoized = moize(method);
expect(moize.isMoized(method)).toBe(false);
expect(moize.isMoized(memoized)).toBe(true);
});
it('should handle random data types', () => {
const types = [undefined, null, 'string', 123, [], {}];
types.forEach((type) => {
expect(moize.isMoized(type)).toBe(false);
});
});
});