Skip to content

Commit f192fc1

Browse files
committed
test/4.js :: added test to verify that source arrays are not modified
1 parent a0636af commit f192fc1

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/4.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
var test = require('tape')
2+
, streamify = require('..')
3+
, concat = require('concat-stream')
4+
;
5+
6+
test('immutable', function(t) {
7+
var s, a = [1, 2, 3, 4, 5];
8+
9+
if (Object && 'function' === typeof(Object.observe)) {
10+
Object.observe(a, function (changes) {
11+
t.fail('input array has been modified');
12+
});
13+
}
14+
15+
s = streamify(a);
16+
17+
s.pipe(concat({encoding: 'object'}, function(res) {
18+
t.equal(1, arguments.length, 'concat returns 1 arg');
19+
t.deepEqual(a, res, 'result array matches input');
20+
t.end();
21+
}));
22+
});

0 commit comments

Comments
 (0)