1 | const test = require('tape');
|
2 | const { callOrNothingAtAll } = require('./function');
|
3 |
|
4 | test('callOrNothingAtAll()', assert => {
|
5 | {
|
6 | const actual = callOrNothingAtAll();
|
7 | const expected = undefined;
|
8 | const message = 'returns `undefined` if no function is provided';
|
9 |
|
10 | assert.equal(actual, expected, message);
|
11 | }
|
12 | {
|
13 | const getAnswer = () => '42';
|
14 |
|
15 | const actual = callOrNothingAtAll(getAnswer);
|
16 | const expected = '42';
|
17 | const message = 'returns the return value of the provided function';
|
18 |
|
19 | assert.equal(actual, expected, message);
|
20 | }
|
21 | {
|
22 | const getAnswer = answer => answer;
|
23 | const argumentList = ['42'];
|
24 |
|
25 | const actual = callOrNothingAtAll(getAnswer, argumentList);
|
26 | const expected = '42';
|
27 | const message =
|
28 | 'calls the provided function with the provided arguments array';
|
29 |
|
30 | assert.equal(actual, expected, message);
|
31 | }
|
32 | {
|
33 | const getAnswer = answer => answer;
|
34 | const getArgumentList = () => ['42'];
|
35 |
|
36 | const actual = callOrNothingAtAll(getAnswer, getArgumentList);
|
37 | const expected = '42';
|
38 | const message =
|
39 | 'calls the provided function with the return value of the provided arguments getter';
|
40 |
|
41 | assert.equal(actual, expected, message);
|
42 | }
|
43 | assert.end();
|
44 | });
|