Added tests for new ordering helper functions and updated changelog

This commit is contained in:
Alejandro Celaya 2021-12-25 19:58:40 +01:00
parent 49c841ca07
commit 3274088b54
4 changed files with 18 additions and 6 deletions

View file

@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
* [#535](https://github.com/shlinkio/shlink-web-client/pull/535) Allowed editing default domain redirects when consuming Shlink 2.10 or newer.
* [#531](https://github.com/shlinkio/shlink-web-client/pull/531) Added custom slug field to the basic creation form in the Overview page.
* [#537](https://github.com/shlinkio/shlink-web-client/pull/537) Allowed to customize the ordering for every list in the app that supports it, being currently tags and short URLs.
* [#542](https://github.com/shlinkio/shlink-web-client/pull/542) Added ordering for short URLs to the query, so that it is consistent with the rest of the filtering params.
### Changed
* [#534](https://github.com/shlinkio/shlink-web-client/pull/534) Updated axios.

View file

@ -12,7 +12,6 @@ import Paginator from '../../src/short-urls/Paginator';
import { ReachableServer } from '../../src/servers/data';
import { ShortUrlListRouteParams } from '../../src/short-urls/helpers/hooks';
import { Settings } from '../../src/settings/reducers/settings';
import ShortUrlsFilteringBar from '../../src/short-urls/ShortUrlsFilteringBar';
describe('<ShortUrlsList />', () => {
let wrapper: ShallowWrapper;

View file

@ -34,7 +34,7 @@ describe('date', () => {
});
describe('isBetween', () => {
test.each([
it.each([
[ now, undefined, undefined, true ],
[ now, subDays(now, 1), undefined, true ],
[ now, now, undefined, true ],
@ -52,7 +52,7 @@ describe('date', () => {
});
describe('isBeforeOrEqual', () => {
test.each([
it.each([
[ now, now, true ],
[ now, addDays(now, 1), true ],
[ now, subDays(now, 1), false ],

View file

@ -1,4 +1,4 @@
import { determineOrderDir } from '../../../src/utils/helpers/ordering';
import { determineOrderDir, OrderDir, orderToString, stringToOrder } from '../../../src/utils/helpers/ordering';
describe('ordering', () => {
describe('determineOrderDir', () => {
@ -24,10 +24,22 @@ describe('ordering', () => {
});
describe('orderToString', () => {
test.todo('casts the order to string');
it.each([
[{}, undefined ],
[{ field: 'foo' }, undefined ],
[{ field: 'foo', dir: 'ASC' as OrderDir }, 'foo-ASC' ],
[{ field: 'bar', dir: 'DESC' as OrderDir }, 'bar-DESC' ],
])('casts the order to string', (order, expectedResult) => {
expect(orderToString(order)).toEqual(expectedResult);
});
});
describe('stringToOrder', () => {
test.todo('casts a string to an order objects');
it.each([
[ 'foo-ASC', { field: 'foo', dir: 'ASC' }],
[ 'bar-DESC', { field: 'bar', dir: 'DESC' }],
])('casts a string to an order objects', (order, expectedResult) => {
expect(stringToOrder(order)).toEqual(expectedResult);
});
});
});