installed pty
[VSoRC/.git] / node_modules / node-pty / lib / terminal.test.js
1 "use strict";
2 /**
3  * Copyright (c) 2017, Daniel Imms (MIT License).
4  * Copyright (c) 2018, Microsoft Corporation (MIT License).
5  */
6 Object.defineProperty(exports, "__esModule", { value: true });
7 var assert = require("assert");
8 var windowsTerminal_1 = require("./windowsTerminal");
9 var unixTerminal_1 = require("./unixTerminal");
10 var terminalConstructor = (process.platform === 'win32') ? windowsTerminal_1.WindowsTerminal : unixTerminal_1.UnixTerminal;
11 var SHELL = (process.platform === 'win32') ? 'cmd.exe' : '/bin/bash';
12 var terminalCtor;
13 if (process.platform === 'win32') {
14     terminalCtor = require('./windowsTerminal');
15 }
16 else {
17     terminalCtor = require('./unixTerminal');
18 }
19 describe('Terminal', function () {
20     describe('constructor', function () {
21         it('should do basic type checks', function () {
22             assert.throws(function () { return new terminalCtor('a', 'b', { 'name': {} }); }, 'name must be a string (not a object)');
23         });
24     });
25     describe('automatic flow control', function () {
26         it('should respect ctor flow control options', function () {
27             var pty = new terminalConstructor(SHELL, [], { handleFlowControl: true, flowControlPause: 'abc', flowControlResume: '123' });
28             assert.equal(pty.handleFlowControl, true);
29             assert.equal(pty._flowControlPause, 'abc');
30             assert.equal(pty._flowControlResume, '123');
31         });
32         // TODO: I don't think this test ever worked due to pollUntil being used incorrectly
33         // it('should do flow control automatically', async function(): Promise<void> {
34         //   // Flow control doesn't work on Windows
35         //   if (process.platform === 'win32') {
36         //     return;
37         //   }
38         //   this.timeout(10000);
39         //   const pty = new terminalConstructor(SHELL, [], {handleFlowControl: true, flowControlPause: 'PAUSE', flowControlResume: 'RESUME'});
40         //   let read: string = '';
41         //   pty.on('data', data => read += data);
42         //   pty.on('pause', () => read += 'paused');
43         //   pty.on('resume', () => read += 'resumed');
44         //   pty.write('1');
45         //   pty.write('PAUSE');
46         //   pty.write('2');
47         //   pty.write('RESUME');
48         //   pty.write('3');
49         //   await pollUntil(() => {
50         //     return stripEscapeSequences(read).endsWith('1pausedresumed23');
51         //   }, 100, 10);
52         // });
53     });
54 });
55 function stripEscapeSequences(data) {
56     return data.replace(/\u001b\[0K/, '');
57 }
58 //# sourceMappingURL=terminal.test.js.map