@gravity-ui/data-source
Version:
A wrapper around data fetching
30 lines • 947 B
JavaScript
import { idle } from '../../constants';
import { composeKey } from '../composeKey';
describe('composeKey', function () {
var dataSource = {
name: 'test',
fetch: jest.fn()
};
it('should compose key with idle params', function () {
var result = composeKey(dataSource, idle);
expect(result).toBe('test:idle');
});
it('should compose key with string param', function () {
var params = 'string';
var result = composeKey(dataSource, params);
expect(result).toBe('test("string")');
});
it('should compose key with object param', function () {
var params = {
id: 1
};
var result = composeKey(dataSource, params);
expect(result).toMatch(/^test\(.+\)$/);
});
it('should compose key with array param', function () {
var params = [1, 2, 3];
var result = composeKey(dataSource, params);
expect(result).toMatch(/^test\(.+\)$/);
});
});
// #sourceMappingURL=composeKey.test.js.map