Skip to content

Commit

Permalink
Merge pull request chjj#68 from Tyriar/fix_encoding_tests
Browse files Browse the repository at this point in the history
Fix encoding test
  • Loading branch information
Tyriar authored Mar 31, 2017
2 parents ffff0b9 + dafdac2 commit 884aa0b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
19 changes: 10 additions & 9 deletions test/unixTerminal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ describe("UnixTerminal", function() {
});
it("should return a Buffer when encoding is null", function(done) {
const term = new UnixTerminal(null, [ '-c', 'cat "' + __dirname + '/utf8-character.txt"' ], {
encoding: null,
});
encoding: null,
});
term.on('data', function(data) {
assert.equal(typeof data, 'object');
assert.ok(data instanceof Buffer);
Expand All @@ -44,16 +44,17 @@ describe("UnixTerminal", function() {
});
});
it("should support other encodings", function(done) {
const term = new UnixTerminal(null, [ '-c', 'cat "' + __dirname + '/utf8-sentence.txt"' ], {
encoding: 'base64'
});
var buf = '';
const text = 'test æ!';
const term = new UnixTerminal(null, ['-c', 'echo "' + text + '"'], {
encoding: 'base64'
});
let buffer = '';
term.on('data', function(data) {
assert.equal(typeof data, 'string');
buf += data;
buffer += data;
});
term.on('close', function() {
assert.equal(buf, 'SGV5LCDDpiEgV2hhZGR1cD8=');
term.on('exit', function() {
assert.equal(new Buffer(buffer, 'base64').toString().replace('\r', '').replace('\n', ''), text);
done();
});
});
Expand Down
1 change: 0 additions & 1 deletion test/utf8-sentence.txt

This file was deleted.

0 comments on commit 884aa0b

Please sign in to comment.