@lableb/javascript-sdk
Version:
Lableb cloud search client for javascript
46 lines (34 loc) • 1.03 kB
text/typescript
import { customIdentity, customPickBy, skipEmptyObject } from './functional';
test('test custom identity function', () => {
expect(customIdentity(3)).toEqual(3);
expect(customIdentity(0)).toEqual('0');
expect(customIdentity('')).toEqual('');
expect(customIdentity(false)).toEqual(false);
});
test('test custom pick by', () => {
let input = {
stringValue: 'hello',
emptyString: '',
zeroValue: 0,
falsy: false,
}
let output = {
stringValue: 'hello',
zeroValue: 0,
}
expect(customPickBy(input, customIdentity)).toEqual(output)
expect(customPickBy(undefined, customIdentity)).toEqual(undefined)
});
test('test skipping empty object', () => {
let input = {
url: 'https://example.com',
params: {
q:'hello'
},
headers: {},
body: {}
}
let output = skipEmptyObject(input);
expect(output).not.toHaveProperty('headers');
expect(output).not.toHaveProperty('body');
});