mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-04-19 04:56:17 +00:00
Updated to airbnb coding styles
This commit is contained in:
@@ -37,16 +37,16 @@ describe('<DateRangeSelector />', () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
[ undefined, 0 ],
|
||||
[ 'all' as DateInterval, 1 ],
|
||||
[ 'today' as DateInterval, 1 ],
|
||||
[ 'yesterday' as DateInterval, 1 ],
|
||||
[ 'last7Days' as DateInterval, 1 ],
|
||||
[ 'last30Days' as DateInterval, 1 ],
|
||||
[ 'last90Days' as DateInterval, 1 ],
|
||||
[ 'last180Days' as DateInterval, 1 ],
|
||||
[ 'last365Days' as DateInterval, 1 ],
|
||||
[{ startDate: new Date() }, 0 ],
|
||||
[undefined, 0],
|
||||
['all' as DateInterval, 1],
|
||||
['today' as DateInterval, 1],
|
||||
['yesterday' as DateInterval, 1],
|
||||
['last7Days' as DateInterval, 1],
|
||||
['last30Days' as DateInterval, 1],
|
||||
['last90Days' as DateInterval, 1],
|
||||
['last180Days' as DateInterval, 1],
|
||||
['last365Days' as DateInterval, 1],
|
||||
[{ startDate: new Date() }, 0],
|
||||
])('sets proper element as active based on provided date range', (initialDateRange, expectedActiveIntervalItems) => {
|
||||
const wrapper = createWrapper({ initialDateRange });
|
||||
const dateIntervalItems = wrapper.find(DateIntervalDropdownItems).filterWhere(
|
||||
|
||||
@@ -15,19 +15,19 @@ describe('date-types', () => {
|
||||
|
||||
describe('dateRangeIsEmpty', () => {
|
||||
it.each([
|
||||
[ undefined, true ],
|
||||
[{}, true ],
|
||||
[{ startDate: null }, true ],
|
||||
[{ endDate: null }, true ],
|
||||
[{ startDate: null, endDate: null }, true ],
|
||||
[{ startDate: undefined }, true ],
|
||||
[{ endDate: undefined }, true ],
|
||||
[{ startDate: undefined, endDate: undefined }, true ],
|
||||
[{ startDate: undefined, endDate: null }, true ],
|
||||
[{ startDate: null, endDate: undefined }, true ],
|
||||
[{ startDate: new Date() }, false ],
|
||||
[{ endDate: new Date() }, false ],
|
||||
[{ startDate: new Date(), endDate: new Date() }, false ],
|
||||
[undefined, true],
|
||||
[{}, true],
|
||||
[{ startDate: null }, true],
|
||||
[{ endDate: null }, true],
|
||||
[{ startDate: null, endDate: null }, true],
|
||||
[{ startDate: undefined }, true],
|
||||
[{ endDate: undefined }, true],
|
||||
[{ startDate: undefined, endDate: undefined }, true],
|
||||
[{ startDate: undefined, endDate: null }, true],
|
||||
[{ startDate: null, endDate: undefined }, true],
|
||||
[{ startDate: new Date() }, false],
|
||||
[{ endDate: new Date() }, false],
|
||||
[{ startDate: new Date(), endDate: new Date() }, false],
|
||||
])('returns proper result', (dateRange, expectedResult) => {
|
||||
expect(dateRangeIsEmpty(dateRange)).toEqual(expectedResult);
|
||||
});
|
||||
@@ -35,10 +35,10 @@ describe('date-types', () => {
|
||||
|
||||
describe('rangeIsInterval', () => {
|
||||
it.each([
|
||||
[ undefined, false ],
|
||||
[{}, false ],
|
||||
[ 'today' as DateInterval, true ],
|
||||
[ 'yesterday' as DateInterval, true ],
|
||||
[undefined, false],
|
||||
[{}, false],
|
||||
['today' as DateInterval, true],
|
||||
['yesterday' as DateInterval, true],
|
||||
])('returns proper result', (range, expectedResult) => {
|
||||
expect(rangeIsInterval(range)).toEqual(expectedResult);
|
||||
});
|
||||
@@ -46,25 +46,25 @@ describe('date-types', () => {
|
||||
|
||||
describe('rangeOrIntervalToString', () => {
|
||||
it.each([
|
||||
[ undefined, undefined ],
|
||||
[ 'today' as DateInterval, 'Today' ],
|
||||
[ 'yesterday' as DateInterval, 'Yesterday' ],
|
||||
[ 'last7Days' as DateInterval, 'Last 7 days' ],
|
||||
[ 'last30Days' as DateInterval, 'Last 30 days' ],
|
||||
[ 'last90Days' as DateInterval, 'Last 90 days' ],
|
||||
[ 'last180Days' as DateInterval, 'Last 180 days' ],
|
||||
[ 'last365Days' as DateInterval, 'Last 365 days' ],
|
||||
[{}, undefined ],
|
||||
[{ startDate: null }, undefined ],
|
||||
[{ endDate: null }, undefined ],
|
||||
[{ startDate: null, endDate: null }, undefined ],
|
||||
[{ startDate: undefined }, undefined ],
|
||||
[{ endDate: undefined }, undefined ],
|
||||
[{ startDate: undefined, endDate: undefined }, undefined ],
|
||||
[{ startDate: undefined, endDate: null }, undefined ],
|
||||
[{ startDate: null, endDate: undefined }, undefined ],
|
||||
[{ startDate: parseDate('2020-01-01', 'yyyy-MM-dd') }, 'Since 2020-01-01' ],
|
||||
[{ endDate: parseDate('2020-01-01', 'yyyy-MM-dd') }, 'Until 2020-01-01' ],
|
||||
[undefined, undefined],
|
||||
['today' as DateInterval, 'Today'],
|
||||
['yesterday' as DateInterval, 'Yesterday'],
|
||||
['last7Days' as DateInterval, 'Last 7 days'],
|
||||
['last30Days' as DateInterval, 'Last 30 days'],
|
||||
['last90Days' as DateInterval, 'Last 90 days'],
|
||||
['last180Days' as DateInterval, 'Last 180 days'],
|
||||
['last365Days' as DateInterval, 'Last 365 days'],
|
||||
[{}, undefined],
|
||||
[{ startDate: null }, undefined],
|
||||
[{ endDate: null }, undefined],
|
||||
[{ startDate: null, endDate: null }, undefined],
|
||||
[{ startDate: undefined }, undefined],
|
||||
[{ endDate: undefined }, undefined],
|
||||
[{ startDate: undefined, endDate: undefined }, undefined],
|
||||
[{ startDate: undefined, endDate: null }, undefined],
|
||||
[{ startDate: null, endDate: undefined }, undefined],
|
||||
[{ startDate: parseDate('2020-01-01', 'yyyy-MM-dd') }, 'Since 2020-01-01'],
|
||||
[{ endDate: parseDate('2020-01-01', 'yyyy-MM-dd') }, 'Until 2020-01-01'],
|
||||
[
|
||||
{ startDate: parseDate('2020-01-01', 'yyyy-MM-dd'), endDate: parseDate('2021-02-02', 'yyyy-MM-dd') },
|
||||
'2020-01-01 - 2021-02-02',
|
||||
@@ -75,17 +75,17 @@ describe('date-types', () => {
|
||||
});
|
||||
|
||||
describe('intervalToDateRange', () => {
|
||||
const formatted = (date?: Date | null): string | undefined => !date ? undefined : format(date, 'yyyy-MM-dd');
|
||||
const formatted = (date?: Date | null): string | undefined => (!date ? undefined : format(date, 'yyyy-MM-dd'));
|
||||
|
||||
it.each([
|
||||
[ undefined, undefined, undefined ],
|
||||
[ 'today' as DateInterval, now(), now() ],
|
||||
[ 'yesterday' as DateInterval, daysBack(1), daysBack(1) ],
|
||||
[ 'last7Days' as DateInterval, daysBack(7), now() ],
|
||||
[ 'last30Days' as DateInterval, daysBack(30), now() ],
|
||||
[ 'last90Days' as DateInterval, daysBack(90), now() ],
|
||||
[ 'last180Days' as DateInterval, daysBack(180), now() ],
|
||||
[ 'last365Days' as DateInterval, daysBack(365), now() ],
|
||||
[undefined, undefined, undefined],
|
||||
['today' as DateInterval, now(), now()],
|
||||
['yesterday' as DateInterval, daysBack(1), daysBack(1)],
|
||||
['last7Days' as DateInterval, daysBack(7), now()],
|
||||
['last30Days' as DateInterval, daysBack(30), now()],
|
||||
['last90Days' as DateInterval, daysBack(90), now()],
|
||||
['last180Days' as DateInterval, daysBack(180), now()],
|
||||
['last365Days' as DateInterval, daysBack(365), now()],
|
||||
])('returns proper result', (interval, expectedStartDate, expectedEndDate) => {
|
||||
const { startDate, endDate } = intervalToDateRange(interval);
|
||||
|
||||
@@ -96,22 +96,22 @@ describe('date-types', () => {
|
||||
|
||||
describe('dateToMatchingInterval', () => {
|
||||
it.each([
|
||||
[ startOfDay(now()), 'today' ],
|
||||
[ now(), 'today' ],
|
||||
[ formatISO(now()), 'today' ],
|
||||
[ daysBack(1), 'yesterday' ],
|
||||
[ endOfDay(daysBack(1)), 'yesterday' ],
|
||||
[ daysBack(2), 'last7Days' ],
|
||||
[ daysBack(7), 'last7Days' ],
|
||||
[ startOfDay(daysBack(7)), 'last7Days' ],
|
||||
[ daysBack(18), 'last30Days' ],
|
||||
[ daysBack(29), 'last30Days' ],
|
||||
[ daysBack(58), 'last90Days' ],
|
||||
[ startOfDay(daysBack(90)), 'last90Days' ],
|
||||
[ daysBack(120), 'last180Days' ],
|
||||
[ daysBack(250), 'last365Days' ],
|
||||
[ daysBack(366), 'all' ],
|
||||
[ formatISO(daysBack(500)), 'all' ],
|
||||
[startOfDay(now()), 'today'],
|
||||
[now(), 'today'],
|
||||
[formatISO(now()), 'today'],
|
||||
[daysBack(1), 'yesterday'],
|
||||
[endOfDay(daysBack(1)), 'yesterday'],
|
||||
[daysBack(2), 'last7Days'],
|
||||
[daysBack(7), 'last7Days'],
|
||||
[startOfDay(daysBack(7)), 'last7Days'],
|
||||
[daysBack(18), 'last30Days'],
|
||||
[daysBack(29), 'last30Days'],
|
||||
[daysBack(58), 'last90Days'],
|
||||
[startOfDay(daysBack(90)), 'last90Days'],
|
||||
[daysBack(120), 'last180Days'],
|
||||
[daysBack(250), 'last365Days'],
|
||||
[daysBack(366), 'all'],
|
||||
[formatISO(daysBack(500)), 'all'],
|
||||
])('returns the first interval which contains provided date', (date, expectedInterval) => {
|
||||
expect(dateToMatchingInterval(date)).toEqual(expectedInterval);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user