@gravity-ui/data-source
Version:
A wrapper around data fetching
23 lines • 974 B
JavaScript
import { mergeStatuses } from '../mergeStatuses';
describe('mergeStatuses', function () {
it('should return success when all statuses are success', function () {
var statuses = ['success', 'success', 'success'];
expect(mergeStatuses(statuses)).toBe('success');
});
it('should return loading when at least one status is loading', function () {
var statuses = ['success', 'loading', 'success'];
expect(mergeStatuses(statuses)).toBe('loading');
});
it('should return error when at least one status is error', function () {
var statuses = ['success', 'error', 'success'];
expect(mergeStatuses(statuses)).toBe('error');
});
it('should prioritize error over loading', function () {
var statuses = ['loading', 'error', 'success'];
expect(mergeStatuses(statuses)).toBe('error');
});
it('should handle empty array', function () {
expect(mergeStatuses([])).toBe('success');
});
});
// #sourceMappingURL=mergeStatuses.test.js.map