feat: anime-companion 插件骨架與設定 (#3)
兩個角色 skill 空殼(sao-asuna、sao-suguha)、userConfig(預設角色、強度、稱呼)、 設定解析與測試,並登錄到 marketplace。 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
b0ed5efedf
commit
8db7181825
@@ -0,0 +1,43 @@
|
||||
import { describe, expect, test } from 'claude-code/testing'
|
||||
|
||||
import { addressFor, resolveConfig } from './config'
|
||||
|
||||
describe('resolveConfig', () => {
|
||||
test('空設定用預設值', () => {
|
||||
expect(resolveConfig({})).toEqual({ character: null, intensity: 2, address: null })
|
||||
})
|
||||
|
||||
test('none 與未知角色都視為未設定', () => {
|
||||
expect(resolveConfig({ defaultCharacter: 'none' }).character).toBeNull()
|
||||
expect(resolveConfig({ defaultCharacter: 'sao-nobody' }).character).toBeNull()
|
||||
})
|
||||
|
||||
test('讀取角色、強度與稱呼', () => {
|
||||
expect(resolveConfig({ defaultCharacter: 'sao-suguha', intensity: '3', address: ' 阿桐 ' })).toEqual({
|
||||
character: 'sao-suguha',
|
||||
intensity: 3,
|
||||
address: '阿桐',
|
||||
})
|
||||
})
|
||||
|
||||
test('無效強度退回預設', () => {
|
||||
expect(resolveConfig({ intensity: '9' }).intensity).toBe(2)
|
||||
expect(resolveConfig({ intensity: 'x' }).intensity).toBe(2)
|
||||
})
|
||||
|
||||
test('強度 0 有效', () => {
|
||||
expect(resolveConfig({ intensity: '0' }).intensity).toBe(0)
|
||||
})
|
||||
})
|
||||
|
||||
describe('addressFor', () => {
|
||||
test('沒有覆寫時依角色與使用者的關係', () => {
|
||||
const config = resolveConfig({})
|
||||
expect(addressFor(config, 'sao-asuna')).toBe('桐人')
|
||||
expect(addressFor(config, 'sao-suguha')).toBe('哥哥')
|
||||
})
|
||||
|
||||
test('覆寫優先', () => {
|
||||
expect(addressFor(resolveConfig({ address: '主人' }), 'sao-asuna')).toBe('主人')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user