-
-
Notifications
You must be signed in to change notification settings - Fork 178
Expand file tree
/
Copy pathutils.test.ts
More file actions
30 lines (26 loc) · 951 Bytes
/
utils.test.ts
File metadata and controls
30 lines (26 loc) · 951 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { describe, test } from 'vitest'
import type { StringChange } from './types'
import { spliceChangesIntoString } from './utils'
describe('spliceChangesIntoString', () => {
test('can apply changes to a string', ({ expect }) => {
let str = 'the quick brown fox jumps over the lazy dog'
let changes: StringChange[] = [
//
{ start: 10, end: 15, before: 'brown', after: 'purple' },
]
expect(spliceChangesIntoString(str, changes)).toBe(
'the quick purple fox jumps over the lazy dog',
)
})
test('changes are applied in order', ({ expect }) => {
let str = 'the quick brown fox jumps over the lazy dog'
let changes: StringChange[] = [
//
{ start: 10, end: 15, before: 'brown', after: 'purple' },
{ start: 4, end: 9, before: 'quick', after: 'slow' },
]
expect(spliceChangesIntoString(str, changes)).toBe(
'the slow purple fox jumps over the lazy dog',
)
})
})