no-args.js 810 B

123456789101112131415161718192021222324252627282930
  1. var Memoizerific = require('../src/memoizerific');
  2. describe("no args", () => {
  3. var memoizedFn,
  4. res,
  5. arg1 = null,
  6. arg2 = undefined,
  7. arg3 = NaN; // important to test since NaN does not equal NaN
  8. beforeEach(function() {
  9. memoizedFn = Memoizerific(50)(function() {
  10. return 'no args';
  11. });
  12. memoizedFn();
  13. });
  14. it("should be map or similar", () => { expect(memoizedFn.cache instanceof Map).toEqual(process.env.FORCE_SIMILAR_INSTEAD_OF_MAP !== 'true'); });
  15. it("should be memoized", () => {
  16. res = memoizedFn();
  17. expect(res).toEqual('no args');
  18. expect(memoizedFn.wasMemoized).toEqual(true);
  19. expect(memoizedFn.lru.length).toEqual(1);
  20. res = memoizedFn();
  21. expect(res).toEqual('no args');
  22. expect(memoizedFn.wasMemoized).toEqual(true);
  23. expect(memoizedFn.lru.length).toEqual(1);
  24. });
  25. });