Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions test/mocha.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--timeout 20000
37 changes: 37 additions & 0 deletions test/unixTerminal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,41 @@ describe("UnixTerminal", function() {
}
});
});

describe("PtyForkEncodingOption", function() {
it("should default to utf8", function(done) {
const term = new UnixTerminal(null, [ '-c', 'cat "' + __dirname + '/utf8-character.txt"' ]);
term.on('data', function(data) {
assert.equal(typeof data, 'string');
assert.equal(data, '\u00E6');
done();
});
});
it("should return a Buffer when encoding is null", function(done) {
const term = new UnixTerminal(null, [ '-c', 'cat "' + __dirname + '/utf8-character.txt"' ], {
encoding: null,
});
term.on('data', function(data) {
assert.equal(typeof data, 'object');
assert.ok(data instanceof Buffer);
assert.equal(0xC3, data[0]);
assert.equal(0xA6, data[1]);
done();
});
});
it("should support other encodings", function(done) {
const term = new UnixTerminal(null, [ '-c', 'cat "' + __dirname + '/utf8-sentence.txt"' ], {
encoding: 'base64'
});
var buf = '';
term.on('data', function(data) {
assert.equal(typeof data, 'string');
buf += data;
});
term.on('close', function() {
assert.equal(buf, 'SGV5LCDDpiEgV2hhZGR1cD8=');
done();
});
});
});
});
1 change: 1 addition & 0 deletions test/utf8-character.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
æ
1 change: 1 addition & 0 deletions test/utf8-sentence.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hey, æ! Whaddup?