hexo/node_modules/moize/__tests__/deepEqual.ts

27 lines
584 B
TypeScript
Raw Normal View History

2023-09-25 15:58:56 +08:00
import moize from '../src';
type Arg = {
one: number;
two: {
deep: 2;
};
};
const method = jest.fn(function ({ one, two }: Arg) {
return [one, two.deep];
});
const memoized = moize.deep(method);
describe('moize.deep', () => {
it('should memoized based on the deep values', () => {
const resultA = memoized({ one: 1, two: { deep: 2 } });
const resultB = memoized({ one: 1, two: { deep: 2 } });
expect(resultA).toEqual([1, 2]);
expect(resultA).toBe(resultB);
expect(method).toHaveBeenCalledTimes(1);
});
});