Skip to content

Commit

Permalink
fix: add logs for date utils
Browse files Browse the repository at this point in the history
  • Loading branch information
phatnguyenuit committed Jan 23, 2021
1 parent 92129fe commit d652236
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/components/weather/daily-weather/__test__/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
/* eslint-disable no-console */
import dayjs from 'dayjs';
import { DATE_FORMAT, TIME_ZONE } from 'constants/common';
import * as utils from '../utils';

dayjs.tz.setDefault(TIME_ZONE);

describe('formatDate', () => {
test('should work', () => {
const today = dayjs.tz(dayjs(), TIME_ZONE);
Expand All @@ -11,15 +14,18 @@ describe('formatDate', () => {

describe('computeDisplayDate', () => {
test('should return today', () => {
const today = dayjs.tz(dayjs(), TIME_ZONE);
const today = dayjs();
console.log('today', today.format(DATE_FORMAT));
expect(utils.computeDisplayDate(today)).toEqual('Today');
});
test('should return tomorrow', () => {
const tomorrow = dayjs.tz(dayjs(), TIME_ZONE).add(1, 'day');
const tomorrow = dayjs().add(1, 'day');
console.log('tomorrow', tomorrow.format(DATE_FORMAT));
expect(utils.computeDisplayDate(tomorrow)).toEqual('Tomorrow');
});
test('should return the formatted date', () => {
const next2DaysDate = dayjs.tz(dayjs(), TIME_ZONE).add(2, 'day');
const next2DaysDate = dayjs().add(2, 'day');
console.log('next2DaysDate', next2DaysDate.format(DATE_FORMAT));
expect(utils.computeDisplayDate(next2DaysDate)).toEqual(
next2DaysDate.format(DATE_FORMAT),
);
Expand Down

1 comment on commit d652236

@vercel
Copy link

@vercel vercel bot commented on d652236 Jan 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.