forked from boos/BoosAPI
e0a5f57793
Vendor the rebranded BoosAPI Desktop client (Tauri + Vue) into metapi as a monorepo subdirectory under desktop/. Source only — node_modules, dist, Cargo target and the upstream .git history are excluded. desktop/ keeps its own independent Cargo workspace (desktop/src-tauri with crates/*); it is not part of the backend boosapi crate, so a `cargo check` at the metapi root still compiles only the backend. Build the desktop app from desktop/src-tauri per desktop/README.md. Note: app icons are still placeholder assets pending the final BoosAPI logo. The updater signing keys live outside the repo and are not included.
49 lines
1.4 KiB
TypeScript
49 lines
1.4 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { computeMinimalEdit } from '../src/minimalEdit'
|
|
|
|
describe('computeMinimalEdit', () => {
|
|
it('no-op when equal', () => {
|
|
expect(computeMinimalEdit('abc', 'abc')).toBeNull()
|
|
})
|
|
|
|
it('append only', () => {
|
|
const res = computeMinimalEdit('abc', 'abcdef')!
|
|
expect(res.start).toBe(3)
|
|
expect(res.replaceText).toBe('def')
|
|
})
|
|
|
|
it('prepend only', () => {
|
|
const res = computeMinimalEdit('world', 'hello world')!
|
|
expect(res.start).toBe(0)
|
|
expect(res.replaceText).toBe('hello ')
|
|
})
|
|
|
|
it('middle change', () => {
|
|
const res = computeMinimalEdit('aXc', 'aYc')!
|
|
expect(res.start).toBe(1)
|
|
expect(res.replaceText).toBe('Y')
|
|
})
|
|
|
|
it('replace all (prev empty)', () => {
|
|
const res = computeMinimalEdit('', 'foo')!
|
|
expect(res.start).toBe(0)
|
|
expect(res.replaceText).toBe('foo')
|
|
})
|
|
|
|
it('replace all (next empty)', () => {
|
|
const res = computeMinimalEdit('bar', '')!
|
|
expect(res.start).toBe(0)
|
|
expect(res.replaceText).toBe('')
|
|
})
|
|
|
|
it('emoji (UTF-16) consistency', () => {
|
|
// 😀 is surrogate pair (U+1F600)
|
|
const prev = 'hi😀'
|
|
const next = 'hi😀 there'
|
|
const res = computeMinimalEdit(prev, next)!
|
|
// start should be at prev.length (4 UTF-16 code units: h i surrogate pair)
|
|
expect(res.start).toBe(prev.length)
|
|
expect(res.replaceText).toBe(' there')
|
|
})
|
|
})
|