このコミットが含まれているのは:
2026-11-01 00:20:32 +09:00
コミット 74c5242828
22個のファイルの変更、202行の追加、232行の削除
+17 -1
ファイルの表示
@@ -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 })