mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-04-21 14:06:19 +00:00
Replaced most of the usages of moment with date-fns
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import moment from 'moment';
|
||||
import { formatISO, parse } from 'date-fns';
|
||||
import { formatDate, formatIsoDate } from '../../../src/utils/helpers/date';
|
||||
|
||||
describe('date', () => {
|
||||
describe('formatDate', () => {
|
||||
it.each([
|
||||
[ moment('2020-03-05 10:00:10'), 'DD/MM/YYYY', '05/03/2020' ],
|
||||
[ moment('2020-03-05 10:00:10'), 'YYYY-MM', '2020-03' ],
|
||||
[ moment('2020-03-05 10:00:10'), undefined, '2020-03-05' ],
|
||||
[ '2020-03-05 10:00:10', 'DD-MM-YYYY', '2020-03-05 10:00:10' ],
|
||||
[ parse('2020-03-05 10:00:10', 'yyyy-MM-dd HH:mm:ss', new Date()), 'dd/MM/yyyy', '05/03/2020' ],
|
||||
[ parse('2020-03-05 10:00:10', 'yyyy-MM-dd HH:mm:ss', new Date()), 'yyyy-MM', '2020-03' ],
|
||||
[ parse('2020-03-05 10:00:10', 'yyyy-MM-dd HH:mm:ss', new Date()), 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 ],
|
||||
@@ -18,7 +18,10 @@ describe('date', () => {
|
||||
|
||||
describe('formatIsoDate', () => {
|
||||
it.each([
|
||||
[ moment('2020-03-05 10:00:10'), moment('2020-03-05 10:00:10').format() ],
|
||||
[
|
||||
parse('2020-03-05 10:00:10', 'yyyy-MM-dd HH:mm:ss', new Date()),
|
||||
formatISO(parse('2020-03-05 10:00:10', 'yyyy-MM-dd HH:mm:ss', new Date())),
|
||||
],
|
||||
[ '2020-03-05 10:00:10', '2020-03-05 10:00:10' ],
|
||||
[ 'foo', 'foo' ],
|
||||
[ undefined, undefined ],
|
||||
|
||||
Reference in New Issue
Block a user