@gravity-ui/data-source
Version:
A wrapper around data fetching
25 lines • 1.01 kB
JavaScript
import { nullSymbol, undefinedSymbol } from '../../constants';
import { formatNullableValue } from '../formatNullableValue';
describe('formatNullableValue', function () {
it('should return undefinedSymbol for undefined', function () {
expect(formatNullableValue(undefined)).toBe(undefinedSymbol);
});
it('should return nullSymbol for null', function () {
expect(formatNullableValue(null)).toBe(nullSymbol);
});
it('should return the value for non-nullable values', function () {
expect(formatNullableValue(42)).toBe(42);
expect(formatNullableValue(0)).toBe(0);
expect(formatNullableValue('test')).toBe('test');
expect(formatNullableValue('')).toBe('');
expect(formatNullableValue(true)).toBe(true);
expect(formatNullableValue(false)).toBe(false);
var obj = {
a: 1
};
expect(formatNullableValue(obj)).toBe(obj);
var arr = [1, 2, 3];
expect(formatNullableValue(arr)).toBe(arr);
});
});
// #sourceMappingURL=formatNullableValue.test.js.map