feat: load tweet conversations
This commit is contained in:
@@ -1,5 +1,51 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { buildSearchQuery, normalizeUserTarget } from './inputs'
|
||||
import {
|
||||
buildSearchQuery,
|
||||
normalizeTweetId,
|
||||
normalizeUserTarget,
|
||||
threadPageInputSchema,
|
||||
} from './inputs'
|
||||
|
||||
describe('threadPageInputSchema', () => {
|
||||
it('accepts initial and complete continuation requests', () => {
|
||||
expect(threadPageInputSchema.parse({ tweetId: '123' })).toEqual({
|
||||
tweetId: '123',
|
||||
})
|
||||
expect(
|
||||
threadPageInputSchema.parse({
|
||||
tweetId: '123',
|
||||
conversationId: '100',
|
||||
cursor: 'thread-next',
|
||||
}),
|
||||
).toEqual({
|
||||
tweetId: '123',
|
||||
conversationId: '100',
|
||||
cursor: 'thread-next',
|
||||
})
|
||||
})
|
||||
|
||||
it.each([
|
||||
{ tweetId: '' },
|
||||
{ tweetId: 'abc' },
|
||||
{ tweetId: '123', cursor: 'thread-next' },
|
||||
{ tweetId: '123', conversationId: '100' },
|
||||
{ tweetId: '123', conversationId: 'root', cursor: 'thread-next' },
|
||||
])('rejects an invalid thread request %#', (input) => {
|
||||
expect(() => threadPageInputSchema.parse(input)).toThrow()
|
||||
})
|
||||
})
|
||||
|
||||
describe('normalizeTweetId', () => {
|
||||
it('keeps a decimal post ID', () => {
|
||||
expect(normalizeTweetId(' 1234567890 ')).toBe('1234567890')
|
||||
})
|
||||
|
||||
it.each(['', '123/status', '@123', '123'])('rejects %s', (input) => {
|
||||
expect(() => normalizeTweetId(input)).toThrow(
|
||||
'投稿 ID を確認してください。',
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('normalizeUserTarget', () => {
|
||||
it.each([
|
||||
|
||||
Reference in New Issue
Block a user