アイヌ語追加 (#428) (#433)

Reviewed-on: #433
Co-authored-by: miteruzo <miteruzo@naver.com>
このコミットはプルリクエスト #433 でマージされました。
このコミットが含まれているのは:
2026-10-20 20:44:14 +09:00
committed by みてるぞ
コミット 084a090cab
294個のファイルの変更、13978行の追加、3461行の削除
+37 -5
ファイルの表示
@@ -1,14 +1,46 @@
import { describe, expect, it } from 'vitest'
import { QueryClient } from '@tanstack/react-query'
import { postsKeys, tagsKeys, wikiKeys } from '@/lib/queryKeys'
import type { FetchNicoTagsParams } from '@/types'
describe ('query keys', () => {
it ('uses stable namespaces for posts, tags, and wiki', () => {
expect (postsKeys.show ('3')).toEqual (['posts', '3'])
expect (postsKeys.related ('3')).toEqual (['related', '3'])
expect (tagsKeys.deerjikists ('7')).toEqual (['tags', 'deerjikists', '7'])
expect (postsKeys.show ('3')).toEqual (['posts', 'ja', '3'])
expect (postsKeys.related ('3')).toEqual (['related', 'ja', '3'])
expect (tagsKeys.deerjikists ('7')).toEqual (['tags', 'ja', 'deerjikists', '7'])
expect (wikiKeys.show ('Title', { version: '2' })).toEqual (
['wiki', 'Title', { version: '2' }],
)
['wiki', 'ja', 'Title', { version: '2' }])
})
it ('isolates the same resource by viewing locale', () => {
const client = new QueryClient ()
client.setQueryData (postsKeys.show ('3', 'ja'), { title: '日本語' })
client.setQueryData (postsKeys.show ('3', 'ain-Kana'), { title: 'アイヌ語' })
expect (client.getQueryData (postsKeys.show ('3', 'ja'))).toEqual ({ title: '日本語' })
expect (client.getQueryData (postsKeys.show ('3', 'ain-Kana')))
.toEqual ({ title: 'アイヌ語' })
client.clear ()
})
it ('invalidates both nico locales without invalidating ordinary tags', async () => {
const client = new QueryClient ()
const params: FetchNicoTagsParams = {
name: '', linkedTag: '', linkStatus: 'all', page: 1, limit: 20,
order: 'name:asc' }
const ja = tagsKeys.nicoIndex (params, 'ja')
const ain = tagsKeys.nicoIndex (params, 'ain-Kana')
const ordinary = tagsKeys.show ('3', 'ja')
for (const key of [ja, ain, ordinary])
client.setQueryData (key, [])
await client.invalidateQueries ({ queryKey: tagsKeys.nicoRoot })
expect (client.getQueryState (ja)?.isInvalidated).toBe (true)
expect (client.getQueryState (ain)?.isInvalidated).toBe (true)
expect (client.getQueryState (ordinary)?.isInvalidated).toBe (false)
client.clear ()
})
})