UNPKG

1.35 kBJavaScriptView Raw
1"use strict";
2
3var test = require('tape');
4
5var _require = require('./iterable'),
6 reduceMap = _require.reduceMap;
7
8test('reduceMap()', function (assert) {
9 var createMap = function createMap() {
10 return new Map([[function () {
11 return false;
12 }, function () {
13 return false;
14 }], [function (first, second) {
15 return second === 'b';
16 }, function (third, fourth) {
17 return fourth;
18 }]]);
19 };
20
21 {
22 var actual = reduceMap({
23 map: createMap(),
24 keyArguments: ['a', 'b'],
25 valueArguments: ['c', 'd']
26 });
27 var expected = 'd';
28 var message = 'returns the output of the first value function where the key function is truthy';
29 assert.equal(actual, expected, message);
30 }
31 {
32 var _actual = reduceMap({
33 map: createMap(),
34 fallback: 'foo'
35 });
36
37 var _expected = 'foo';
38 var _message = 'returns the fallback value if there are no matches';
39 assert.equal(_actual, _expected, _message);
40 }
41 {
42 var _actual2 = reduceMap({
43 map: createMap(),
44 valueArguments: ['c', 'd'],
45 fallback: function fallback(first, second) {
46 return second;
47 }
48 });
49
50 var _expected2 = 'd';
51 var _message2 = 'supports fallback as a function, with the functionArgs supplied';
52 assert.equal(_actual2, _expected2, _message2);
53 }
54 assert.end();
55});
\No newline at end of file