Reviewed-on: #359 Co-authored-by: miteruzo <miteruzo@naver.com> Co-committed-by: miteruzo <miteruzo@naver.com>
このコミットはPull リクエスト #359 でマージされました.
このコミットが含まれているのは:
@@ -8,12 +8,19 @@ const dialogue = vi.hoisted (() => ({
|
||||
confirm: vi.fn (),
|
||||
}))
|
||||
|
||||
const nicoViewer = vi.hoisted (() => ({
|
||||
props: vi.fn (),
|
||||
}))
|
||||
|
||||
vi.mock ('@/components/dialogues/DialogueProvider', () => ({
|
||||
useDialogue: () => dialogue,
|
||||
}))
|
||||
|
||||
vi.mock ('@/components/NicoViewer', () => ({
|
||||
default: ({ id }: { id: string }) => <div>Nico:{id}</div>,
|
||||
default: (props: { id: string }) => {
|
||||
nicoViewer.props (props)
|
||||
return <div>Nico:{props.id}</div>
|
||||
},
|
||||
}))
|
||||
|
||||
vi.mock ('react-youtube', () => ({
|
||||
@@ -31,6 +38,64 @@ describe ('PostEmbed', () => {
|
||||
expect (screen.getByText ('Nico:sm12345')).toBeInTheDocument ()
|
||||
})
|
||||
|
||||
it ('reports niconico metadata as milliseconds', () => {
|
||||
const onVideoReady = vi.fn ()
|
||||
const onPlaybackChange = vi.fn ()
|
||||
render (
|
||||
<PostEmbed
|
||||
post={buildPost ({ url: 'https://www.nicovideo.jp/watch/sm12345' })}
|
||||
onVideoReady={onVideoReady}
|
||||
onPlaybackChange={onPlaybackChange}/>,
|
||||
)
|
||||
|
||||
nicoViewer.props.mock.calls[0][0].onMetadataChange ({
|
||||
currentTime: 7_000,
|
||||
duration: 120_000,
|
||||
isVideoMetaDataLoaded: true,
|
||||
maximumBuffered: 30,
|
||||
muted: false,
|
||||
showComment: true,
|
||||
volume: 1,
|
||||
})
|
||||
|
||||
expect (onVideoReady).toHaveBeenCalledWith (120_000)
|
||||
expect (onPlaybackChange).toHaveBeenCalledWith (7_000)
|
||||
})
|
||||
|
||||
it ('reports niconico video readiness only once', () => {
|
||||
const onVideoReady = vi.fn ()
|
||||
render (
|
||||
<PostEmbed
|
||||
post={buildPost ({ url: 'https://www.nicovideo.jp/watch/sm12345' })}
|
||||
onVideoReady={onVideoReady}/>,
|
||||
)
|
||||
|
||||
nicoViewer.props.mock.calls[0][0].onLoadComplete ({
|
||||
title: '動画',
|
||||
videoId: 'sm12345',
|
||||
lengthInSeconds: 120,
|
||||
thumbnailUrl: 'https://example.com/thumb.jpg',
|
||||
description: '',
|
||||
viewCount: 1,
|
||||
commentCount: 2,
|
||||
mylistCount: 3,
|
||||
postedAt: '2026-01-02T03:04:05.000Z',
|
||||
watchId: 12345,
|
||||
})
|
||||
nicoViewer.props.mock.calls[0][0].onMetadataChange ({
|
||||
currentTime: 7_000,
|
||||
duration: 120_000,
|
||||
isVideoMetaDataLoaded: true,
|
||||
maximumBuffered: 30,
|
||||
muted: false,
|
||||
showComment: true,
|
||||
volume: 1,
|
||||
})
|
||||
|
||||
expect (onVideoReady).toHaveBeenCalledTimes (1)
|
||||
expect (onVideoReady).toHaveBeenCalledWith (120_000)
|
||||
})
|
||||
|
||||
it ('embeds x/twitter status URLs', () => {
|
||||
render (<PostEmbed post={buildPost ({ url: 'https://x.com/someone/status/12345' })}/>)
|
||||
|
||||
|
||||
新しい課題から参照
ユーザをブロックする