mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 01:47:48 +00:00
wip: code formatting nits continued
This commit is contained in:
28
test/tap.spec.js
Normal file
28
test/tap.spec.js
Normal file
@@ -0,0 +1,28 @@
|
||||
describe('tap', () => {
|
||||
it('should intercept and return the given value', () => {
|
||||
let intercepted;
|
||||
const array = [1, 2, 3];
|
||||
|
||||
const actual = _.tap(array, (value) => {
|
||||
intercepted = value;
|
||||
});
|
||||
|
||||
expect(actual).toBe(array);
|
||||
expect(intercepted).toBe(array);
|
||||
});
|
||||
|
||||
it('should intercept unwrapped values and return wrapped values when chaining', () => {
|
||||
let intercepted;
|
||||
const array = [1, 2, 3];
|
||||
|
||||
const wrapped = _(array).tap((value) => {
|
||||
intercepted = value;
|
||||
value.pop();
|
||||
});
|
||||
|
||||
expect(wrapped instanceof _);
|
||||
|
||||
wrapped.value();
|
||||
expect(intercepted).toBe(array);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user