Skip to content

Commit

Permalink
test: update tests for reset
Browse files Browse the repository at this point in the history
  • Loading branch information
KermanX committed Feb 4, 2024
1 parent 9705681 commit 49ef2f5
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions test/MagicString.js
Expand Up @@ -1275,14 +1275,26 @@ describe('MagicString', () => {
assert.equal(s.toString(), 'acdefgi');
});

it('should not reset content inserted after the end of removed range', () => {
it('should reset modified ranges, redux', () => {
const s = new MagicString('abcdefghi');

s.remove(1, 8);
s.appendLeft(2, 'W');
s.appendRight(2, 'X');
s.prependLeft(3, 'Y');
s.prependRight(5, 'Z');
s.reset(2, 7);
assert.equal(s.toString(), 'aWcdefgi');
});

it('should not reset content inserted after the end of range', () => {
const s = new MagicString('ab.c;');

s.prependRight(0, '(');
s.prependRight(4, ')');
s.remove(2, 4);
s.reset(2, 3);
assert.equal(s.toString(), '(ab.);');
s.remove(1, 4);
s.reset(2, 4);
assert.equal(s.toString(), '(a.c);');
});

it('should provide a useful error when illegal removals are attempted', () => {
Expand Down

0 comments on commit 49ef2f5

Please sign in to comment.