Tech

코드 블록 테스트

2022. 12. 22
describe('Test suite of date', () => {
  test('Test getDayjsDate', () => {
    expect(nowDate.format()).toBe(dummyNowDate);
    expect(eventStartDate.format()).toBe(EVENT_START_DATE_KST);
    expect(couponPublishStartDate.format()).toBe(COUPON_PUBLISH_START_DATE_KST);
    expect(couponPublishEndDate.format()).toBe(COUPON_PUBLISH_END_DATE_KST);
  });

  test('Test format to add utcOffset(9)', () => {
    expect(getDayjsWithTZ('2022-11-22T14:00:00').format()).toBe(
      '2022-11-22T14:00:00+09:00',
    );
    expect(getDayjsWithTZ('2022-11-22T10:00:00').format()).toBe(
      '2022-11-22T10:00:00+09:00',
    );
  });

  test('Test isBefore', () => {
    expect(nowDate.isBefore(eventStartDate)).toBe(true);
  });

  test('Test isBetween', () => {
    expect(
      nowDate.isBetween(couponPublishStartDate, couponPublishEndDate),
    ).toBe(true);
  });
});

연관 아티클