このコミットが含まれているのは:
@@ -1,6 +1,7 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { fetchPostChanges, fetchPosts, toggleViewedFlg, updatePost } from '@/lib/posts'
|
||||
import { fetchPostChanges, fetchPosts, switchPostFilterLocale, toggleViewedFlg, updatePost }
|
||||
from '@/lib/posts'
|
||||
|
||||
import type { FetchPostsParams } from '@/types'
|
||||
|
||||
@@ -34,6 +35,21 @@ describe ('posts API functions', () => {
|
||||
vi.clearAllMocks ()
|
||||
})
|
||||
|
||||
it ('switches current tag names without adding identity state to the URL', async () => {
|
||||
api.apiGet.mockResolvedValueOnce ({ tags: 'シロシ not:nico:shared' })
|
||||
const path = await switchPostFilterLocale ({
|
||||
location: { pathname: '/ja/counts/posts',
|
||||
search: '?tags=source+not%3Anico%3Ashared&match=any', hash: '#table' },
|
||||
params: {}, locale: 'ja', targetLocale: 'ain-Kana' })
|
||||
expect (api.apiGet).toHaveBeenCalledWith ('/posts/tag_filters', {
|
||||
locale: 'ja', params: { tags: 'source not:nico:shared', target_locale: 'ain-Kana' } })
|
||||
const url = new URL (path, 'https://example.test')
|
||||
expect (url.pathname).toBe ('/ain-Kana/counts/posts')
|
||||
expect (Object.fromEntries (url.searchParams)).toEqual ({
|
||||
tags: 'シロシ not:nico:shared', match: 'any' })
|
||||
expect (url.hash).toBe ('#table')
|
||||
})
|
||||
|
||||
it ('maps post search parameters to backend snake_case names', async () => {
|
||||
api.apiGet.mockResolvedValueOnce ({ posts: [], count: 0 })
|
||||
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする