1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | var __extends = (this && this.__extends) || (function () {
|
7 | var extendStatics = function (d, b) {
|
8 | extendStatics = Object.setPrototypeOf ||
|
9 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
10 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
11 | return extendStatics(d, b);
|
12 | };
|
13 | return function (d, b) {
|
14 | extendStatics(d, b);
|
15 | function __() { this.constructor = d; }
|
16 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
17 | };
|
18 | })();
|
19 | Object.defineProperty(exports, "__esModule", { value: true });
|
20 | var assert = require("assert");
|
21 | var windowsTerminal_1 = require("./windowsTerminal");
|
22 | var unixTerminal_1 = require("./unixTerminal");
|
23 | var terminal_1 = require("./terminal");
|
24 | var terminalConstructor = (process.platform === 'win32') ? windowsTerminal_1.WindowsTerminal : unixTerminal_1.UnixTerminal;
|
25 | var SHELL = (process.platform === 'win32') ? 'cmd.exe' : '/bin/bash';
|
26 | var terminalCtor;
|
27 | if (process.platform === 'win32') {
|
28 | terminalCtor = require('./windowsTerminal');
|
29 | }
|
30 | else {
|
31 | terminalCtor = require('./unixTerminal');
|
32 | }
|
33 | var TestTerminal = (function (_super) {
|
34 | __extends(TestTerminal, _super);
|
35 | function TestTerminal() {
|
36 | return _super !== null && _super.apply(this, arguments) || this;
|
37 | }
|
38 | TestTerminal.prototype.checkType = function (name, value, type, allowArray) {
|
39 | if (allowArray === void 0) { allowArray = false; }
|
40 | this._checkType(name, value, type, allowArray);
|
41 | };
|
42 | TestTerminal.prototype._write = function (data) {
|
43 | throw new Error('Method not implemented.');
|
44 | };
|
45 | TestTerminal.prototype.resize = function (cols, rows) {
|
46 | throw new Error('Method not implemented.');
|
47 | };
|
48 | TestTerminal.prototype.destroy = function () {
|
49 | throw new Error('Method not implemented.');
|
50 | };
|
51 | TestTerminal.prototype.kill = function (signal) {
|
52 | throw new Error('Method not implemented.');
|
53 | };
|
54 | Object.defineProperty(TestTerminal.prototype, "process", {
|
55 | get: function () {
|
56 | throw new Error('Method not implemented.');
|
57 | },
|
58 | enumerable: true,
|
59 | configurable: true
|
60 | });
|
61 | Object.defineProperty(TestTerminal.prototype, "master", {
|
62 | get: function () {
|
63 | throw new Error('Method not implemented.');
|
64 | },
|
65 | enumerable: true,
|
66 | configurable: true
|
67 | });
|
68 | Object.defineProperty(TestTerminal.prototype, "slave", {
|
69 | get: function () {
|
70 | throw new Error('Method not implemented.');
|
71 | },
|
72 | enumerable: true,
|
73 | configurable: true
|
74 | });
|
75 | return TestTerminal;
|
76 | }(terminal_1.Terminal));
|
77 | describe('Terminal', function () {
|
78 | describe('constructor', function () {
|
79 | it('should do basic type checks', function () {
|
80 | assert.throws(function () { return new terminalCtor('a', 'b', { 'name': {} }); }, 'name must be a string (not a object)');
|
81 | });
|
82 | });
|
83 | describe('checkType', function () {
|
84 | it('should throw for the wrong type', function () {
|
85 | var t = new TestTerminal();
|
86 | assert.doesNotThrow(function () { return t.checkType('foo', 'test', 'string'); });
|
87 | assert.doesNotThrow(function () { return t.checkType('foo', 1, 'number'); });
|
88 | assert.doesNotThrow(function () { return t.checkType('foo', {}, 'object'); });
|
89 | assert.throws(function () { return t.checkType('foo', 'test', 'number'); });
|
90 | assert.throws(function () { return t.checkType('foo', 1, 'object'); });
|
91 | assert.throws(function () { return t.checkType('foo', {}, 'string'); });
|
92 | });
|
93 | it('should throw for wrong types within arrays', function () {
|
94 | var t = new TestTerminal();
|
95 | assert.doesNotThrow(function () { return t.checkType('foo', ['test'], 'string', true); });
|
96 | assert.doesNotThrow(function () { return t.checkType('foo', [1], 'number', true); });
|
97 | assert.doesNotThrow(function () { return t.checkType('foo', [{}], 'object', true); });
|
98 | assert.throws(function () { return t.checkType('foo', ['test'], 'number', true); });
|
99 | assert.throws(function () { return t.checkType('foo', [1], 'object', true); });
|
100 | assert.throws(function () { return t.checkType('foo', [{}], 'string', true); });
|
101 | });
|
102 | });
|
103 | describe('automatic flow control', function () {
|
104 | it('should respect ctor flow control options', function () {
|
105 | var pty = new terminalConstructor(SHELL, [], { handleFlowControl: true, flowControlPause: 'abc', flowControlResume: '123' });
|
106 | assert.equal(pty.handleFlowControl, true);
|
107 | assert.equal(pty._flowControlPause, 'abc');
|
108 | assert.equal(pty._flowControlResume, '123');
|
109 | });
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 |
|
131 | });
|
132 | });
|
133 | function stripEscapeSequences(data) {
|
134 | return data.replace(/\u001b\[0K/, '');
|
135 | }
|
136 |
|
\ | No newline at end of file |