35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { getTweetDates, getTweetId, tweetIdToDate } from "./getAnnounceUrlDetails";
|
|
import { test, expect, describe } from 'vitest';
|
|
|
|
describe('getAnnounceUrlDetails integration', () => {
|
|
test("getTweets", async () => {
|
|
|
|
const testData = [
|
|
{
|
|
announceUrl: 'https://x.com/ProjektMelody/status/1989881851817988146',
|
|
listedDate: '2025-11-16T02:22:58.000Z',
|
|
expectedDate: '2025-11-16T02:22:58.347Z'
|
|
}, {
|
|
announceUrl: 'https://x.com/ProjektMelody/status/1266096281002356736',
|
|
listedDate: '2020-05-28T19:57:30.000Z',
|
|
expectedDate: '2020-05-28T19:57:30.979Z',
|
|
}, {
|
|
announceUrl: 'https://x.com/ProjektMelody/status/1481416541493153795',
|
|
listedDate: '2022-01-13T00:03:21.000Z',
|
|
expectedDate: '2022-01-13T00:03:21.537Z',
|
|
}
|
|
]
|
|
|
|
const data = testData.map((datum) => ({ ...datum, date: tweetIdToDate(getTweetId(datum.announceUrl)) }))
|
|
|
|
for (const datum of data) {
|
|
|
|
expect(datum.date).toBeTruthy();
|
|
expect(new Date(datum.date)).toStrictEqual(new Date(datum.expectedDate));
|
|
|
|
}
|
|
}, 30000);
|
|
|
|
|
|
})
|