wip: code formatting nits continued

This commit is contained in:
jdalton
2023-09-16 22:59:56 -07:00
parent 0b28b7f7b6
commit b5c59317ea
421 changed files with 7354 additions and 9005 deletions

39
test/result.spec.js Normal file
View File

@@ -0,0 +1,39 @@
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', () => {
expect(result(object, 'b')).toBe('b');
});
it('should invoke default function values', () => {
const actual = result(object, 'c', object.b);
expect(actual).toBe('b');
});
it('should invoke nested function values', () => {
const value = { a: lodashStable.constant({ b: stubB }) };
lodashStable.each(['a.b', ['a', 'b']], (path) => {
expect(result(value, path)).toBe('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) => {
expect(result(value, path)).toBe(1);
});
});
});