Fix unit tests

This commit is contained in:
Daniel Imms 2022-03-11 14:29:08 -08:00
parent 3164ed22a0
commit b38f0a6b97
3 changed files with 12 additions and 11 deletions

View file

@ -13,6 +13,7 @@ export interface IXtermCore {
viewport?: {
_innerRefresh(): void;
};
_onData: IEventEmitter<string>;
_onKey: IEventEmitter<{ key: string }>;
_charSizeService: {

View file

@ -43,11 +43,11 @@ suite('PartialCommandDetectionCapability', () => {
test('should not add commands when the cursor position is too close to the left side', async () => {
assertCommands([]);
xterm._core._onKey.fire({ key: '\x0d' });
xterm._core._onData.fire('\x0d');
await writeP(xterm, '\r\n');
assertCommands([]);
await writeP(xterm, 'a');
xterm._core._onKey.fire({ key: '\x0d' });
xterm._core._onData.fire('\x0d');
await writeP(xterm, '\r\n');
assertCommands([]);
});
@ -55,11 +55,11 @@ suite('PartialCommandDetectionCapability', () => {
test('should add commands when the cursor position is not too close to the left side', async () => {
assertCommands([]);
await writeP(xterm, 'ab');
xterm._core._onKey.fire({ key: '\x0d' });
xterm._core._onData.fire('\x0d');
await writeP(xterm, '\r\n\r\n');
assertCommands([0]);
await writeP(xterm, 'cd');
xterm._core._onKey.fire({ key: '\x0d' });
xterm._core._onData.fire('\x0d');
await writeP(xterm, '\r\n');
assertCommands([0, 2]);
});

View file

@ -62,13 +62,13 @@ suite('Workbench - TerminalCommandTracker', function () {
test('should track commands when the prompt is of sufficient size', async () => {
assert.strictEqual(xterm.markers.length, 0);
await writeP(xterm, '\x1b[3G'); // Move cursor to column 3
xterm._core._onKey.fire({ key: '\x0d' });
xterm._core._onData.fire('\x0d');
assert.strictEqual(xterm.markers.length, 1);
});
test('should not track commands when the prompt is too small', async () => {
assert.strictEqual(xterm.markers.length, 0);
await writeP(xterm, '\x1b[2G'); // Move cursor to column 2
xterm._core._onKey.fire({ key: '\x0d' });
xterm._core._onData.fire('\x0d');
assert.strictEqual(xterm.markers.length, 0);
});
});
@ -85,7 +85,7 @@ suite('Workbench - TerminalCommandTracker', function () {
});
test('should scroll to the next and previous commands', async () => {
await writeP(xterm, '\x1b[3G'); // Move cursor to column 3
xterm._core._onKey.fire({ key: '\x0d' }); // Mark line #10
xterm._core._onData.fire('\x0d'); // Mark line #10
assert.strictEqual(xterm.markers[0].line, 9);
await writeP(xterm, `\r\n`.repeat(20));
@ -114,13 +114,13 @@ suite('Workbench - TerminalCommandTracker', function () {
'\n\r1' +
'\x1b[3G' // Move cursor to column 3
);
xterm._core._onKey.fire({ key: '\x0d' }); // Mark line
xterm._core._onData.fire('\x0d'); // Mark line
assert.strictEqual(xterm.markers[0].line, 10);
await writeP(xterm,
'\n\r2' +
'\x1b[3G' // Move cursor to column 3
);
xterm._core._onKey.fire({ key: '\x0d' }); // Mark line
xterm._core._onData.fire('\x0d'); // Mark line
assert.strictEqual(xterm.markers[1].line, 11);
await writeP(xterm, '\n\r3');
@ -143,13 +143,13 @@ suite('Workbench - TerminalCommandTracker', function () {
'\n\r1' +
'\x1b[3G' // Move cursor to column 3
);
xterm._core._onKey.fire({ key: '\x0d' }); // Mark line
xterm._core._onData.fire('\x0d'); // Mark line
assert.strictEqual(xterm.markers[0].line, 10);
await writeP(xterm,
'\n\r2' +
'\x1b[3G' // Move cursor to column 3
);
xterm._core._onKey.fire({ key: '\x0d' }); // Mark line
xterm._core._onData.fire('\x0d'); // Mark line
assert.strictEqual(xterm.markers[1].line, 11);
await writeP(xterm, '\n\r3');