diff --git a/test/unixTerminal.test.js b/test/unixTerminal.test.js index 0c7e410..8e41cd2 100644 --- a/test/unixTerminal.test.js +++ b/test/unixTerminal.test.js @@ -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); @@ -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(); }); }); diff --git a/test/utf8-sentence.txt b/test/utf8-sentence.txt deleted file mode 100644 index 5e99e45..0000000 --- a/test/utf8-sentence.txt +++ /dev/null @@ -1 +0,0 @@ -Hey, æ! Whaddup? \ No newline at end of file