兩個角色 skill 空殼(sao-asuna、sao-suguha)、userConfig(預設角色、強度、稱呼)、 設定解析與測試,並登錄到 marketplace。 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
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('主人')
|
|
})
|
|
})
|