mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-03 22:31:52 +00:00
Implemented logic to edit domain redirects
This commit is contained in:
@@ -13,20 +13,26 @@ describe('domainsList', () => {
|
||||
const domains = [ Mock.all<ShlinkDomain>(), Mock.all<ShlinkDomain>(), Mock.all<ShlinkDomain>() ];
|
||||
|
||||
describe('reducer', () => {
|
||||
const action = (type: string, args: Partial<ListDomainsAction> = {}) => Mock.of<ListDomainsAction>(
|
||||
const action = (type: string, args: Partial<ListDomainsAction> = {}): any => Mock.of<ListDomainsAction>(
|
||||
{ type, ...args },
|
||||
);
|
||||
|
||||
it('returns loading on LIST_DOMAINS_START', () => {
|
||||
expect(reducer(undefined, action(LIST_DOMAINS_START))).toEqual({ domains: [], loading: true, error: false });
|
||||
expect(reducer(undefined, action(LIST_DOMAINS_START))).toEqual(
|
||||
{ domains: [], filteredDomains: [], loading: true, error: false },
|
||||
);
|
||||
});
|
||||
|
||||
it('returns error on LIST_DOMAINS_ERROR', () => {
|
||||
expect(reducer(undefined, action(LIST_DOMAINS_ERROR))).toEqual({ domains: [], loading: false, error: true });
|
||||
expect(reducer(undefined, action(LIST_DOMAINS_ERROR))).toEqual(
|
||||
{ domains: [], filteredDomains: [], loading: false, error: true },
|
||||
);
|
||||
});
|
||||
|
||||
it('returns domains on LIST_DOMAINS', () => {
|
||||
expect(reducer(undefined, action(LIST_DOMAINS, { domains }))).toEqual({ domains, loading: false, error: false });
|
||||
expect(reducer(undefined, action(LIST_DOMAINS, { domains }))).toEqual(
|
||||
{ domains, filteredDomains: domains, loading: false, error: false },
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { determineOrderDir, rangeOf } from '../../src/utils/utils';
|
||||
import { determineOrderDir, nonEmptyValueOrNull, rangeOf } from '../../src/utils/utils';
|
||||
|
||||
describe('utils', () => {
|
||||
describe('determineOrderDir', () => {
|
||||
@@ -47,4 +47,17 @@ describe('utils', () => {
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('nonEmptyValueOrNull', () => {
|
||||
it.each([
|
||||
[ '', null ],
|
||||
[ 'Hello', 'Hello' ],
|
||||
[[], null ],
|
||||
[[ 1, 2, 3 ], [ 1, 2, 3 ]],
|
||||
[{}, null ],
|
||||
[{ foo: 'bar' }, { foo: 'bar' }],
|
||||
])('returns expected value based on input', (value, expected) => {
|
||||
expect(nonEmptyValueOrNull(value)).toEqual(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user