Skip to content

Commit beed0e7

Browse files
authored
Fix behavior with string unicodes diffs (#8)
1 parent 09dc983 commit beed0e7

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

β€Žsrc/test/patch.spec.tsβ€Ž

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ describe('Get Patch', () => {
1919
type: 'add',
2020
oldPos,
2121
newPos,
22-
items: str.split(''),
22+
items: [...str],
2323
};
2424
}
2525
function remove(oldPos: number, newPos: number, str: string): es.PatchItem<string> {
2626
return {
2727
type: 'remove',
2828
oldPos,
2929
newPos,
30-
items: str.split(''),
30+
items: [...str],
3131
};
3232
}
3333
function es_str(a: string, b: string, script: es.Patch<string>, msg?: string) {
34-
assert.deepStrictEqual(es.getPatch(a.split(''), b.split('')), script, msg);
34+
assert.deepStrictEqual(es.getPatch([...a], [...b]), script, msg);
3535
}
3636

3737
es_str('', '', [], 'empty');
@@ -103,5 +103,7 @@ describe('Get Patch', () => {
103103
[add(12, 12, '12345678901234567890')],
104104
'remove 12345678901234567890',
105105
);
106+
107+
es_str('πŸ’’πŸ’©πŸ’§', 'πŸ’’πŸ’«πŸ’§', [remove(1, 1, 'πŸ’©'), add(2, 1, 'πŸ’«')], 'works with unicodes');
106108
});
107109
});

β€Žtsconfig.jsonβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"declaration": true,
99
"outDir": "./dist",
1010
"strict": true,
11-
"esModuleInterop": true
11+
"esModuleInterop": true,
12+
"downlevelIteration": true
1213
}
1314
}

0 commit comments

Comments
Β (0)