Skip to content

Commit

Permalink
fix tests more
Browse files Browse the repository at this point in the history
  • Loading branch information
calvinmetcalf committed Aug 8, 2016
1 parent 25ec4c4 commit 7ca6e8e
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 24 deletions.
4 changes: 4 additions & 0 deletions build/test-replacements.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ module.exports['common.js'] = [
, '\n/*<replacement>*/\nvar util = require(\'core-util-is\');\n'
+ 'util.inherits = require(\'inherits\');\n/*</replacement>*/\n'
]
, [
/process\.binding\('timer_wrap'\)\.Timer;/,
'{now: function (){}}'
]
]

// this test has some trouble with the nextTick depth when run
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
},
"scripts": {
"test": "tap test/parallel/*.js test/ours/*.js",
"browser": "npm run write-zuul && zuul -- test/browser.js",
"browser": "npm run write-zuul && zuul --browser-retries 2 -- test/browser.js",
"write-zuul": "printf \"ui: tape\nbrowsers:\n - name: $BROWSER_NAME\n version: $BROWSER_VERSION\n\">.zuul.yml",
"local": "zuul --local -- test/browser.js",
"local": "zuul --local 3000 --no-coverage -- test/browser.js",
"cover": "nyc npm test",
"report": "nyc report --reporter=lcov"
},
Expand Down
3 changes: 1 addition & 2 deletions test/browser/test-stream-push-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ module.exports = function (t) {
// ACTUALLY [1, 3, 5, 6, 4, 2]

setTimeout(function() {
t.deepEqual(s._readableState.buffer,
['1', '2', '3', '4', '5', '6']);
t.equals(s._readableState.buffer.join(','), '1,2,3,4,5,6');
});
});
}
38 changes: 20 additions & 18 deletions test/browser/test-stream2-readable-from-list.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
'use strict';
var common = require('../common');
// Flags: --expose_internals
/*<replacement>*/
var bufferShim = require('buffer-shims');
/*</replacement>*/
require('../common');
var fromList = require('../../lib/_stream_readable')._fromList;
var BufferList = require('../../lib/internal/streams/BufferList');

function bufferListFromArray(arr) {
var bl = new BufferList();
for (var i = 0; i < arr.length; ++i) {
bl.push(arr[i]);
}return bl;
}

module.exports = function (t) {
t.test('buffers', function(t) {
// have a length
var len = 16;
var list = [ new Buffer('foog'),
new Buffer('bark'),
new Buffer('bazy'),
new Buffer('kuel') ];
t.test('buffers', function (t) {
var list = [bufferShim.from('foog'), bufferShim.from('bark'), bufferShim.from('bazy'), bufferShim.from('kuel')];
list = bufferListFromArray(list);

// read more than the first element.
var ret = fromList(6, { buffer: list, length: 16 });
Expand All @@ -29,18 +35,14 @@ module.exports = function (t) {
t.equal(ret.toString(), 'zykuel');

// all consumed.
t.same(list, []);
t.same(list, new BufferList());

t.end();
});

t.test('strings', function(t) {
// have a length
var len = 16;
var list = [ 'foog',
'bark',
'bazy',
'kuel' ];
t.test('strings', function (t) {
var list = ['foog', 'bark', 'bazy', 'kuel'];
list = bufferListFromArray(list);

// read more than the first element.
var ret = fromList(6, { buffer: list, length: 16, decoder: true });
Expand All @@ -59,7 +61,7 @@ module.exports = function (t) {
t.equal(ret, 'zykuel');

// all consumed.
t.same(list, []);
t.same(list, new BufferList());

t.end();
});
Expand Down
2 changes: 1 addition & 1 deletion test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var util = require('core-util-is');
util.inherits = require('inherits');
/*</replacement>*/

var Timer = process.binding('timer_wrap').Timer;
var Timer = { now: function () {} };

var testRoot = path.resolve(process.env.NODE_TEST_DIR || path.dirname(__filename));

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-stream-push-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ s.read(0);
process.on('exit', function () {
assert.deepStrictEqual(s._readableState.buffer.join(','), '1,2,3,4,5,6');
console.log('ok');
});
});

0 comments on commit 7ca6e8e

Please sign in to comment.