Files
30-seconds-of-code/test/memoize/memoize.test.js
Angelos Chalaris a78f5db260 Test migration to jest by hand
Apparently using regular expressions is way easier.
2018-06-18 15:15:56 +03:00

15 lines
405 B
JavaScript

const expect = require('expect');
const memoize = require('./memoize.js');
test('memoize is a Function', () => {
expect(memoize).toBeInstanceOf(Function);
});
const f = x => x * x;
const square = memoize(f);
t.equal(square(2), 4, 'Function works properly');
t.equal(square(3), 9, 'Function works properly');
t.deepEqual(Array.from(square.cache), [[2,4],[3,9]], 'Cache stores values');