import { describe, expect, test } from 'bun:test' import { MARKER_KEY, hasValidMarker, withMarker } from './config-marker.ts' import type { ConfigObject } from '../vendor/config-editor/index.ts' describe('配置标记', () => { test('打上标记后校验通过,其余键不动', () => { const data: ConfigObject = { 'mixed-port': 7890 } const marked = withMarker(data) expect(hasValidMarker(marked)).toBe(true) expect(marked['mixed-port']).toBe(7890) }) test('没有标记、标记形状不对、sig 对不上都算无效', () => { expect(hasValidMarker({})).toBe(false) expect(hasValidMarker({ [MARKER_KEY]: 'yes' })).toBe(false) expect(hasValidMarker({ [MARKER_KEY]: { v: 1, sig: 'deadbeef' } })).toBe(false) }) test('打两次标记结果一样(落盘链路的内容不变检查靠它短路)', () => { const once = withMarker({}) expect(withMarker(once)).toEqual(once) }) })