Skip to content

Commit b0b1db0

Browse files
committed
test: add missing thisArg tests
1 parent 8fb6e3d commit b0b1db0

File tree

1 file changed

+27
-0
lines changed
  • lib/node_modules/@stdlib/array/base/group-indices-by/test

1 file changed

+27
-0
lines changed

lib/node_modules/@stdlib/array/base/group-indices-by/test/test.js

+27
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,30 @@ tape( 'the function returns an empty object if provided an empty array', functio
164164
return v;
165165
}
166166
});
167+
168+
tape( 'the function supports specifying a callback execution context', function test( t ) {
169+
var expected;
170+
var out;
171+
var ctx;
172+
var x;
173+
174+
x = [ 'beep', 'boop', 'foo', 'bar' ];
175+
176+
expected = {
177+
'b': [ 0, 1, 3 ],
178+
'f': [ 2 ]
179+
};
180+
ctx = {
181+
'count': 0
182+
};
183+
out = groupIndicesBy( x, indicator, ctx );
184+
185+
t.deepEqual( out, expected, 'returns expected value' );
186+
t.strictEqual( ctx.count, x.length, 'returns expected value' );
187+
t.end();
188+
189+
function indicator( v ) {
190+
this.count += 1; // eslint-disable-line no-invalid-this
191+
return v[ 0 ];
192+
}
193+
});

0 commit comments

Comments
 (0)