add tests for removing multiple characters in edit
This commit is contained in:
parent
b8a3c5ebd0
commit
4b08bf0e76
1 changed files with 47 additions and 23 deletions
|
@ -19,16 +19,12 @@ import {diffDeletion, diffAtCaret} from "../../src/editor/diff";
|
|||
|
||||
describe('editor/diff', function() {
|
||||
describe('diffDeletion', function() {
|
||||
describe('with a single character removed', function() {
|
||||
it('at start of string', function() {
|
||||
const diff = diffDeletion("hello", "ello");
|
||||
expect(diff.at).toBe(0);
|
||||
expect(diff.removed).toBe("h");
|
||||
});
|
||||
it('removing whole string', function() {
|
||||
const diff = diffDeletion("hello", "");
|
||||
expect(diff.at).toBe(0);
|
||||
expect(diff.removed).toBe("hello");
|
||||
});
|
||||
it('in middle of string', function() {
|
||||
const diff = diffDeletion("hello", "hllo");
|
||||
expect(diff.at).toBe(1);
|
||||
|
@ -45,6 +41,34 @@ describe('editor/diff', function() {
|
|||
expect(diff.removed).toBe("o");
|
||||
});
|
||||
});
|
||||
describe('with a multiple removed', function() {
|
||||
it('at start of string', function() {
|
||||
const diff = diffDeletion("hello", "llo");
|
||||
expect(diff.at).toBe(0);
|
||||
expect(diff.removed).toBe("he");
|
||||
});
|
||||
it('removing whole string', function() {
|
||||
const diff = diffDeletion("hello", "");
|
||||
expect(diff.at).toBe(0);
|
||||
expect(diff.removed).toBe("hello");
|
||||
});
|
||||
it('in middle of string', function() {
|
||||
const diff = diffDeletion("hello", "hlo");
|
||||
expect(diff.at).toBe(1);
|
||||
expect(diff.removed).toBe("el");
|
||||
});
|
||||
it('in middle of string with duplicate character', function() {
|
||||
const diff = diffDeletion("hello", "heo");
|
||||
expect(diff.at).toBe(2);
|
||||
expect(diff.removed).toBe("ll");
|
||||
});
|
||||
it('at end of string', function() {
|
||||
const diff = diffDeletion("hello", "hel");
|
||||
expect(diff.at).toBe(3);
|
||||
expect(diff.removed).toBe("lo");
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('diffAtCaret', function() {
|
||||
it('insert at start', function() {
|
||||
const diff = diffAtCaret("world", "hello world", 6);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue