Files
30-seconds-of-code/test/once.test.js
Christian C. Salvadó 83a6a6ea32 [ENHANCEMENT] Properly configure eslint to work with jest (#988)
* chore: make aware eslint that we use jest

By setting up the jest environment, we no longer need to declare the
'test' global in the configuration.

* chore: don't need to import expect, it's a jest environment global

* chore: don't need to import expect when creating undefined test
2019-06-18 08:34:45 +03:00

14 lines
358 B
JavaScript

const {once} = require('./_30s.js');
test('once is a Function', () => {
expect(once).toBeInstanceOf(Function);
});
test('once returns Function', () => {
expect(typeof once(x => 10)).toBe('function');
});
test('once returns the result only once', () => {
let onced = once(x => x);
expect(onced(10)).toBe(10);
expect(onced(10)).toBe(undefined);
});