Fix shlink-web-component tests

This commit is contained in:
Alejandro Celaya
2023-08-04 11:16:01 +02:00
parent bdcfcee60e
commit 4d8477a32c
54 changed files with 345 additions and 431 deletions

View File

@@ -1,23 +1,9 @@
import { addDays, formatISO, subDays } from 'date-fns';
import { formatDate, formatIsoDate, isBeforeOrEqual, isBetween, parseDate } from '../../../../src/utils/dates/helpers/date';
import { formatIsoDate, isBeforeOrEqual, isBetween, parseDate } from '../../../../src/utils/dates/helpers/date';
describe('date', () => {
const now = new Date();
describe('formatDate', () => {
it.each([
[parseDate('2020-03-05 10:00:10', 'yyyy-MM-dd HH:mm:ss'), 'dd/MM/yyyy', '05/03/2020'],
[parseDate('2020-03-05 10:00:10', 'yyyy-MM-dd HH:mm:ss'), 'yyyy-MM', '2020-03'],
[parseDate('2020-03-05 10:00:10', 'yyyy-MM-dd HH:mm:ss'), undefined, '2020-03-05'],
['2020-03-05 10:00:10', 'dd-MM-yyyy', '2020-03-05 10:00:10'],
['2020-03-05 10:00:10', undefined, '2020-03-05 10:00:10'],
[undefined, undefined, undefined],
[null, undefined, null],
])('formats date as expected', (date, format, expected) => {
expect(formatDate(format)(date)).toEqual(expected);
});
});
describe('formatIsoDate', () => {
it.each([
[

View File

@@ -1,7 +1,7 @@
import { fromPartial } from '@total-typescript/shoehorn';
import type { LocalStorage } from '../../../../src/utils/services/LocalStorage';
import { MAIN_COLOR } from '../../../../src/utils/theme';
import { ColorGenerator } from '../../../src/utils/services/ColorGenerator';
import type { LocalStorage } from '../../../src/utils/services/LocalStorage';
describe('ColorGenerator', () => {
let colorGenerator: ColorGenerator;

View File

@@ -1,5 +1,5 @@
import { render } from '@testing-library/react';
import type { OrderDir } from '../../../../shlink-frontend-kit/src/ordering/ordering';
import type { OrderDir } from '../../../../shlink-frontend-kit/src';
import { TableOrderIcon } from '../../../src/utils/table/TableOrderIcon';
describe('<TableOrderIcon />', () => {