mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 18:07:49 +00:00
wip: migrate to bun
This commit is contained in:
40
test/result.spec.ts
Normal file
40
test/result.spec.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import assert from 'node:assert';
|
||||
import lodashStable from 'lodash';
|
||||
import { stubB } from './utils';
|
||||
import result from '../src/result';
|
||||
|
||||
describe('result', () => {
|
||||
const object = { a: 1, b: stubB };
|
||||
|
||||
it('should invoke function values', () => {
|
||||
assert.strictEqual(result(object, 'b'), 'b');
|
||||
});
|
||||
|
||||
it('should invoke default function values', () => {
|
||||
const actual = result(object, 'c', object.b);
|
||||
assert.strictEqual(actual, 'b');
|
||||
});
|
||||
|
||||
it('should invoke nested function values', () => {
|
||||
const value = { a: lodashStable.constant({ b: stubB }) };
|
||||
|
||||
lodashStable.each(['a.b', ['a', 'b']], (path) => {
|
||||
assert.strictEqual(result(value, path), 'b');
|
||||
});
|
||||
});
|
||||
|
||||
it('should invoke deep property methods with the correct `this` binding', () => {
|
||||
const value = {
|
||||
a: {
|
||||
b: function () {
|
||||
return this.c;
|
||||
},
|
||||
c: 1,
|
||||
},
|
||||
};
|
||||
|
||||
lodashStable.each(['a.b', ['a', 'b']], (path) => {
|
||||
assert.strictEqual(result(value, path), 1);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user