diff --git a/__tests__/lib/blog-helper.test.ts b/__tests__/lib/blog-helper.test.ts index 5b1d6830..87f5ed94 100644 --- a/__tests__/lib/blog-helper.test.ts +++ b/__tests__/lib/blog-helper.test.ts @@ -1,10 +1,28 @@ jest.mock('../../lib/notion/blog-index-cache') import { + getDateStr, isYouTubeURL, parseYouTubeVideoId, } from '../../lib/blog-helpers' +describe('getDateStr', () => { + it('returns str when date has time', async () => { + const got = getDateStr('2022-12-30T00:09:00.000+09:00') + expect(got).toEqual('2022-12-30') + }) + + it('returns str when date has no time', async () => { + const got = getDateStr('2022-12-30') + expect(got).toEqual('2022-12-30') + }) + + it('returns local time str considering timezone', async () => { + const got = getDateStr('2022-12-30T00:00:00.000+09:00') + expect(got).toEqual('2022-12-30') + }) +}) + describe('isYouTubeURL', () => { it('returns false with not YouTube URL', async () => { const got = isYouTubeURL(new URL('https://www.google.com/'))