From 3274088b545d904e3d429d82fb45141f399a43da Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 25 Dec 2021 19:58:40 +0100 Subject: [PATCH] Added tests for new ordering helper functions and updated changelog --- CHANGELOG.md | 1 + test/short-urls/ShortUrlsList.test.tsx | 1 - test/utils/helpers/date.test.ts | 4 ++-- test/utils/helpers/ordering.test.ts | 18 +++++++++++++++--- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18fbd3ab..7f45282c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/test/short-urls/ShortUrlsList.test.tsx b/test/short-urls/ShortUrlsList.test.tsx index da6bfec3..9f9cb65f 100644 --- a/test/short-urls/ShortUrlsList.test.tsx +++ b/test/short-urls/ShortUrlsList.test.tsx @@ -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('', () => { let wrapper: ShallowWrapper; diff --git a/test/utils/helpers/date.test.ts b/test/utils/helpers/date.test.ts index 349fae49..79dae5bf 100644 --- a/test/utils/helpers/date.test.ts +++ b/test/utils/helpers/date.test.ts @@ -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 ], diff --git a/test/utils/helpers/ordering.test.ts b/test/utils/helpers/ordering.test.ts index 20be691b..29111323 100644 --- a/test/utils/helpers/ordering.test.ts +++ b/test/utils/helpers/ordering.test.ts @@ -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); + }); }); });