Skip to content

Commit

Permalink
readline: fix tests failing without internationalization
Browse files Browse the repository at this point in the history
  • Loading branch information
Avi-D-coder committed Feb 19, 2019
1 parent 0639c1b commit 1b9ea93
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions test/parallel/test-readline-interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,11 @@ function isWarned(emitter) {
fi.emit('keypress', '.', { name: 'right' });
cursorPos = rli._getCursorPos();
assert.strictEqual(cursorPos.rows, 0);
assert.strictEqual(cursorPos.cols, 2);
if (common.hasIntl) {
assert.strictEqual(cursorPos.cols, 2);
} else {
assert.strictEqual(cursorPos.cols, 1);
}

rli.on('line', common.mustCall((line) => {
assert.strictEqual(line, 'πŸ’»');
Expand Down Expand Up @@ -700,7 +704,14 @@ function isWarned(emitter) {
fi.emit('data', 'πŸ•');
cursorPos = rli._getCursorPos();
assert.strictEqual(cursorPos.rows, 0);
assert.strictEqual(cursorPos.cols, 2);

if (common.hasIntl) {
assert.strictEqual(cursorPos.cols, 2);
} else {
assert.strictEqual(cursorPos.cols, 1);
// fix cursor position without internationalization
fi.emit('keypress', '.', { name: 'left' });
}

rli.on('line', common.mustCall((line) => {
assert.strictEqual(line, 'πŸ•πŸ’»');
Expand All @@ -724,12 +735,22 @@ function isWarned(emitter) {
fi.emit('keypress', '.', { name: 'right' });
let cursorPos = rli._getCursorPos();
assert.strictEqual(cursorPos.rows, 0);
assert.strictEqual(cursorPos.cols, 2);
if (common.hasIntl) {
assert.strictEqual(cursorPos.cols, 2);
} else {
assert.strictEqual(cursorPos.cols, 1);
// fix cursor position without internationalization
fi.emit('keypress', '.', { name: 'right' });
}

fi.emit('data', 'πŸ•');
cursorPos = rli._getCursorPos();
assert.strictEqual(cursorPos.rows, 0);
assert.strictEqual(cursorPos.cols, 4);
if (common.hasIntl) {
assert.strictEqual(cursorPos.cols, 4);
} else {
assert.strictEqual(cursorPos.cols, 2);
}

rli.on('line', common.mustCall((line) => {
assert.strictEqual(line, 'πŸ’»πŸ•');
Expand Down Expand Up @@ -891,8 +912,11 @@ function isWarned(emitter) {
fi.emit('data', 'πŸ’»');
let cursorPos = rli._getCursorPos();
assert.strictEqual(cursorPos.rows, 0);
assert.strictEqual(cursorPos.cols, 2);

if (common.hasIntl) {
assert.strictEqual(cursorPos.cols, 2);
} else {
assert.strictEqual(cursorPos.cols, 1);
}
// Delete left character
fi.emit('keypress', '.', { ctrl: true, name: 'h' });
cursorPos = rli._getCursorPos();
Expand Down

0 comments on commit 1b9ea93

Please sign in to comment.