feat: validate intentional post requests

This commit is contained in:
2026-07-13 10:21:27 +09:00
parent 92fbcd2242
commit 5873728c30
5 changed files with 185 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
import { describe, expect, it } from 'vitest'
import { flattenPostPages } from './page'
import type { Post, PostPage } from './types'
const post = (id: string): Post => ({
id,
text: `post-${id}`,
author: { username: `user-${id}`, name: `User ${id}` },
})
describe('flattenPostPages', () => {
it('preserves API order and removes duplicate IDs', () => {
const pages: PostPage[] = [
{ tweets: [post('1'), post('2')], nextCursor: 'next' },
{ tweets: [post('2'), post('3')] },
]
expect(flattenPostPages(pages).map(({ id }) => id)).toEqual(['1', '2', '3'])
})
})