bfj 5.3.0 → 6.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +1 -1
- package/.gitlab-ci.yml +25 -0
- package/AUTHORS +1 -1
- package/CONTRIBUTING.md +4 -4
- package/HISTORY.md +46 -0
- package/README.md +172 -66
- package/package.json +9 -9
- package/src/datastream.js +17 -0
- package/src/eventify.js +13 -6
- package/src/events.js +1 -0
- package/src/index.js +1 -0
- package/src/jsonstream.js +6 -12
- package/src/match.js +218 -0
- package/src/parse.js +1 -0
- package/src/stream.js +23 -0
- package/src/streamify.js +26 -13
- package/src/stringify.js +16 -12
- package/src/unpipe.js +1 -1
- package/src/walk.js +2 -2
- package/src/write.js +16 -13
- package/test/integration.js +147 -56
- package/test/unit/datastream.js +95 -0
- package/test/unit/eventify.js +370 -13
- package/test/unit/jsonstream.js +2 -2
- package/test/unit/match.js +1058 -0
- package/test/unit/parse.js +38 -29
- package/test/unit/streamify.js +32 -8
- package/test/unit/stringify.js +21 -4
- package/test/unit/unpipe.js +3 -3
- package/test/unit/walk.js +309 -149
- package/.travis.yml +0 -12
|
@@ -0,0 +1,1058 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const assert = require('chai').assert
|
|
4
|
+
const proxyquire = require('proxyquire')
|
|
5
|
+
const spooks = require('spooks')
|
|
6
|
+
|
|
7
|
+
const modulePath = '../../src/match'
|
|
8
|
+
|
|
9
|
+
suite('match:', () => {
|
|
10
|
+
test('require does not throw', () => {
|
|
11
|
+
assert.doesNotThrow(() => {
|
|
12
|
+
require(modulePath)
|
|
13
|
+
})
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
test('require returns function', () => {
|
|
17
|
+
assert.isFunction(require(modulePath))
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
suite('require, results.push returns true:', () => {
|
|
21
|
+
let log, resume, results, match
|
|
22
|
+
|
|
23
|
+
setup(() => {
|
|
24
|
+
log = {}
|
|
25
|
+
resume = spooks.fn({ name: 'resume', log })
|
|
26
|
+
results = {
|
|
27
|
+
walk: [
|
|
28
|
+
{
|
|
29
|
+
on: spooks.fn({ name: 'on', log: log }),
|
|
30
|
+
pause: spooks.fn({ name: 'pause', log: log, results: [ resume ] })
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
push: [ true ]
|
|
34
|
+
}
|
|
35
|
+
match = proxyquire(modulePath, {
|
|
36
|
+
'./walk': spooks.fn({
|
|
37
|
+
name: 'walk',
|
|
38
|
+
log: log,
|
|
39
|
+
results: results.walk
|
|
40
|
+
}),
|
|
41
|
+
'./datastream': spooks.ctor({
|
|
42
|
+
name: 'DataStream',
|
|
43
|
+
log: log,
|
|
44
|
+
archetype: { instance: { push: () => {}, emit: () => {} } },
|
|
45
|
+
results: results
|
|
46
|
+
})
|
|
47
|
+
})
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
test('match expects two arguments', () => {
|
|
51
|
+
assert.lengthOf(match, 2)
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
test('match does not throw with match function', () => {
|
|
55
|
+
assert.doesNotThrow(() => match(null, () => {}))
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
test('match does not throw with match string', () => {
|
|
59
|
+
assert.doesNotThrow(() => match(null, ' '))
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
test('match throws with empty match string', () => {
|
|
63
|
+
assert.throws(() => match(null, ''))
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
test('match does not throw with match regex', () => {
|
|
67
|
+
assert.doesNotThrow(() => match(null, /.*/))
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
test('match throws with invalid match arg', () => {
|
|
71
|
+
assert.throws(() => match(null, {}))
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
test('match returns stream', () => {
|
|
75
|
+
assert.isFunction(match(null, /.*/).push)
|
|
76
|
+
assert.isFunction(match(null, /.*/).emit)
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
test('DataStream was not called', () => {
|
|
80
|
+
assert.strictEqual(log.counts.DataStream, 0)
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
test('walk was not called', () => {
|
|
84
|
+
assert.strictEqual(log.counts.walk, 0)
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
test('EventEmitter.on was not called', () => {
|
|
88
|
+
assert.strictEqual(log.counts.on, 0)
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
test('EventEmitter.pause was not called', () => {
|
|
92
|
+
assert.strictEqual(log.counts.pause, 0)
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
suite('match with predicate returning true:', () => {
|
|
96
|
+
let stream, predicate, options, result
|
|
97
|
+
|
|
98
|
+
setup(() => {
|
|
99
|
+
stream = {}
|
|
100
|
+
predicate = spooks.fn({ name: 'predicate', log, results: [ true ] })
|
|
101
|
+
options = { foo: 'bar', highWaterMark: 42 }
|
|
102
|
+
result = match(stream, predicate, options)
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
test('DataStream was called once', () => {
|
|
106
|
+
assert.strictEqual(log.counts.DataStream, 1)
|
|
107
|
+
assert.isObject(log.these.DataStream[0])
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
test('DataStream was called correctly', () => {
|
|
111
|
+
assert.lengthOf(log.args.DataStream[0], 2)
|
|
112
|
+
assert.isFunction(log.args.DataStream[0][0])
|
|
113
|
+
assert.deepEqual(log.args.DataStream[0][1], { highWaterMark: 42 })
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
test('walk was called once', () => {
|
|
117
|
+
assert.strictEqual(log.counts.walk, 1)
|
|
118
|
+
assert.isUndefined(log.these.walk[0])
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
test('walk was called correctly', () => {
|
|
122
|
+
assert.lengthOf(log.args.walk[0], 2)
|
|
123
|
+
assert.strictEqual(log.args.walk[0][0], stream)
|
|
124
|
+
assert.lengthOf(Object.keys(log.args.walk[0][0]), 0)
|
|
125
|
+
assert.strictEqual(log.args.walk[0][1], options)
|
|
126
|
+
assert.lengthOf(Object.keys(log.args.walk[0][1]), 2)
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
test('EventEmitter.on was called eleven times', () => {
|
|
130
|
+
assert.strictEqual(log.counts.on, 11)
|
|
131
|
+
assert.strictEqual(log.these.on[0], results.walk[0])
|
|
132
|
+
assert.strictEqual(log.these.on[1], results.walk[0])
|
|
133
|
+
assert.strictEqual(log.these.on[2], results.walk[0])
|
|
134
|
+
assert.strictEqual(log.these.on[3], results.walk[0])
|
|
135
|
+
assert.strictEqual(log.these.on[4], results.walk[0])
|
|
136
|
+
assert.strictEqual(log.these.on[5], results.walk[0])
|
|
137
|
+
assert.strictEqual(log.these.on[6], results.walk[0])
|
|
138
|
+
assert.strictEqual(log.these.on[7], results.walk[0])
|
|
139
|
+
assert.strictEqual(log.these.on[8], results.walk[0])
|
|
140
|
+
assert.strictEqual(log.these.on[9], results.walk[0])
|
|
141
|
+
assert.strictEqual(log.these.on[10], results.walk[0])
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
test('EventEmitter.on was called correctly first time', () => {
|
|
145
|
+
assert.lengthOf(log.args.on[0], 2)
|
|
146
|
+
assert.strictEqual(log.args.on[0][0], 'arr')
|
|
147
|
+
assert.isFunction(log.args.on[0][1])
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
test('EventEmitter.on was called correctly second time', () => {
|
|
151
|
+
assert.lengthOf(log.args.on[1], 2)
|
|
152
|
+
assert.strictEqual(log.args.on[1][0], 'obj')
|
|
153
|
+
assert.isFunction(log.args.on[1][1])
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
test('EventEmitter.on was called correctly third time', () => {
|
|
157
|
+
assert.lengthOf(log.args.on[2], 2)
|
|
158
|
+
assert.strictEqual(log.args.on[2][0], 'pro')
|
|
159
|
+
assert.isFunction(log.args.on[2][1])
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
test('EventEmitter.on was called correctly fourth time', () => {
|
|
163
|
+
assert.lengthOf(log.args.on[3], 2)
|
|
164
|
+
assert.strictEqual(log.args.on[3][0], 'end-arr')
|
|
165
|
+
assert.isFunction(log.args.on[3][1])
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
test('EventEmitter.on was called correctly fifth time', () => {
|
|
169
|
+
assert.lengthOf(log.args.on[4], 2)
|
|
170
|
+
assert.strictEqual(log.args.on[4][0], 'end-obj')
|
|
171
|
+
assert.isFunction(log.args.on[4][1])
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
test('EventEmitter.on was called correctly sixth time', () => {
|
|
175
|
+
assert.lengthOf(log.args.on[5], 2)
|
|
176
|
+
assert.strictEqual(log.args.on[5][0], 'str')
|
|
177
|
+
assert.isFunction(log.args.on[5][1])
|
|
178
|
+
})
|
|
179
|
+
|
|
180
|
+
test('EventEmitter.on was called correctly seventh time', () => {
|
|
181
|
+
assert.lengthOf(log.args.on[6], 2)
|
|
182
|
+
assert.strictEqual(log.args.on[6][0], 'num')
|
|
183
|
+
assert.isFunction(log.args.on[6][1])
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
test('EventEmitter.on was called correctly eighth time', () => {
|
|
187
|
+
assert.lengthOf(log.args.on[7], 2)
|
|
188
|
+
assert.strictEqual(log.args.on[7][0], 'lit')
|
|
189
|
+
assert.isFunction(log.args.on[7][1])
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
test('EventEmitter.on was called correctly ninth time', () => {
|
|
193
|
+
assert.lengthOf(log.args.on[8], 2)
|
|
194
|
+
assert.strictEqual(log.args.on[8][0], 'end')
|
|
195
|
+
assert.isFunction(log.args.on[8][1])
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
test('EventEmitter.on was called correctly tenth time', () => {
|
|
199
|
+
assert.lengthOf(log.args.on[9], 2)
|
|
200
|
+
assert.strictEqual(log.args.on[9][0], 'err')
|
|
201
|
+
assert.isFunction(log.args.on[9][1])
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
test('EventEmitter.on was called correctly eleventh time', () => {
|
|
205
|
+
assert.lengthOf(log.args.on[10], 2)
|
|
206
|
+
assert.strictEqual(log.args.on[10][0], 'err-data')
|
|
207
|
+
assert.isFunction(log.args.on[10][1])
|
|
208
|
+
})
|
|
209
|
+
|
|
210
|
+
suite('array event:', () => {
|
|
211
|
+
setup(() => {
|
|
212
|
+
log.args.on[0][1]()
|
|
213
|
+
})
|
|
214
|
+
|
|
215
|
+
test('results.push was not called', () => {
|
|
216
|
+
assert.strictEqual(log.counts.push, 0)
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
suite('end event:', () => {
|
|
220
|
+
setup(() => {
|
|
221
|
+
log.args.on[8][1]()
|
|
222
|
+
})
|
|
223
|
+
|
|
224
|
+
test('results.push was not called', () => {
|
|
225
|
+
assert.strictEqual(log.counts.push, 0)
|
|
226
|
+
})
|
|
227
|
+
|
|
228
|
+
suite('read stream:', () => {
|
|
229
|
+
setup(() => {
|
|
230
|
+
log.args.DataStream[0][0]()
|
|
231
|
+
})
|
|
232
|
+
|
|
233
|
+
test('results.push was called once', () => {
|
|
234
|
+
assert.strictEqual(log.counts.push, 1)
|
|
235
|
+
})
|
|
236
|
+
|
|
237
|
+
test('results.push was called correctly', () => {
|
|
238
|
+
assert.lengthOf(log.args.push[0], 1)
|
|
239
|
+
assert.isNull(log.args.push[0][0])
|
|
240
|
+
})
|
|
241
|
+
|
|
242
|
+
test('predicate was not called', () => {
|
|
243
|
+
assert.strictEqual(log.counts.predicate, 0)
|
|
244
|
+
})
|
|
245
|
+
})
|
|
246
|
+
})
|
|
247
|
+
|
|
248
|
+
suite('endArray and end events:', () => {
|
|
249
|
+
setup(() => {
|
|
250
|
+
log.args.on[3][1]()
|
|
251
|
+
log.args.on[8][1]()
|
|
252
|
+
})
|
|
253
|
+
|
|
254
|
+
test('predicate was called once', () => {
|
|
255
|
+
assert.strictEqual(log.counts.predicate, 1)
|
|
256
|
+
})
|
|
257
|
+
|
|
258
|
+
test('predicate was called correctly', () => {
|
|
259
|
+
assert.lengthOf(log.args.predicate[0], 3)
|
|
260
|
+
assert.isUndefined(log.args.predicate[0][0])
|
|
261
|
+
assert.deepEqual(log.args.predicate[0][1], [])
|
|
262
|
+
assert.strictEqual(log.args.predicate[0][2], 0)
|
|
263
|
+
})
|
|
264
|
+
|
|
265
|
+
test('results.push was not called', () => {
|
|
266
|
+
assert.strictEqual(log.counts.push, 0)
|
|
267
|
+
})
|
|
268
|
+
|
|
269
|
+
suite('read stream:', () => {
|
|
270
|
+
setup(() => {
|
|
271
|
+
log.args.DataStream[0][0]()
|
|
272
|
+
})
|
|
273
|
+
|
|
274
|
+
test('results.push was called twice', () => {
|
|
275
|
+
assert.strictEqual(log.counts.push, 2)
|
|
276
|
+
})
|
|
277
|
+
|
|
278
|
+
test('results.push was called correctly first time', () => {
|
|
279
|
+
assert.lengthOf(log.args.push[0], 1)
|
|
280
|
+
assert.deepEqual(log.args.push[0][0], [])
|
|
281
|
+
})
|
|
282
|
+
|
|
283
|
+
test('results.push was called correctly second time', () => {
|
|
284
|
+
assert.lengthOf(log.args.push[1], 1)
|
|
285
|
+
assert.isNull(log.args.push[1][0])
|
|
286
|
+
})
|
|
287
|
+
|
|
288
|
+
test('results.emit was not called', () => {
|
|
289
|
+
assert.strictEqual(log.counts.emit, 0)
|
|
290
|
+
})
|
|
291
|
+
})
|
|
292
|
+
})
|
|
293
|
+
|
|
294
|
+
suite('read stream:', () => {
|
|
295
|
+
setup(() => {
|
|
296
|
+
log.args.DataStream[0][0]()
|
|
297
|
+
})
|
|
298
|
+
|
|
299
|
+
test('results.push was not called', () => {
|
|
300
|
+
assert.strictEqual(log.counts.push, 0)
|
|
301
|
+
})
|
|
302
|
+
|
|
303
|
+
suite('end event:', () => {
|
|
304
|
+
setup(() => {
|
|
305
|
+
log.args.on[8][1]()
|
|
306
|
+
})
|
|
307
|
+
|
|
308
|
+
test('results.push was called once', () => {
|
|
309
|
+
assert.strictEqual(log.counts.push, 1)
|
|
310
|
+
})
|
|
311
|
+
|
|
312
|
+
test('results.push was called correctly', () => {
|
|
313
|
+
assert.isNull(log.args.push[0][0])
|
|
314
|
+
})
|
|
315
|
+
|
|
316
|
+
test('results.emit was not called', () => {
|
|
317
|
+
assert.strictEqual(log.counts.emit, 0)
|
|
318
|
+
})
|
|
319
|
+
})
|
|
320
|
+
|
|
321
|
+
suite('dataError event:', () => {
|
|
322
|
+
setup(() => {
|
|
323
|
+
log.args.on[10][1]('foo')
|
|
324
|
+
})
|
|
325
|
+
|
|
326
|
+
test('results.push was not called', () => {
|
|
327
|
+
assert.strictEqual(log.counts.push, 0)
|
|
328
|
+
})
|
|
329
|
+
|
|
330
|
+
test('results.emit was called once', () => {
|
|
331
|
+
assert.strictEqual(log.counts.emit, 1)
|
|
332
|
+
})
|
|
333
|
+
|
|
334
|
+
test('results.emit was called correctly', () => {
|
|
335
|
+
assert.lengthOf(log.args.emit[0], 2)
|
|
336
|
+
assert.strictEqual(log.args.emit[0][0], 'dataError')
|
|
337
|
+
assert.strictEqual(log.args.emit[0][1], 'foo')
|
|
338
|
+
})
|
|
339
|
+
|
|
340
|
+
test('predicate was not called', () => {
|
|
341
|
+
assert.strictEqual(log.counts.predicate, 0)
|
|
342
|
+
})
|
|
343
|
+
})
|
|
344
|
+
|
|
345
|
+
suite('string event:', () => {
|
|
346
|
+
setup(() => {
|
|
347
|
+
log.args.on[5][1]('foo')
|
|
348
|
+
})
|
|
349
|
+
|
|
350
|
+
test('predicate was called once', () => {
|
|
351
|
+
assert.strictEqual(log.counts.predicate, 1)
|
|
352
|
+
})
|
|
353
|
+
|
|
354
|
+
test('predicate was called correctly', () => {
|
|
355
|
+
assert.lengthOf(log.args.predicate[0], 3)
|
|
356
|
+
assert.strictEqual(log.args.predicate[0][0], 0)
|
|
357
|
+
assert.strictEqual(log.args.predicate[0][1], 'foo')
|
|
358
|
+
assert.strictEqual(log.args.predicate[0][2], 1)
|
|
359
|
+
})
|
|
360
|
+
|
|
361
|
+
test('results.push was called once', () => {
|
|
362
|
+
assert.strictEqual(log.counts.push, 1)
|
|
363
|
+
})
|
|
364
|
+
|
|
365
|
+
test('results.push was called correctly', () => {
|
|
366
|
+
assert.strictEqual(log.args.push[0][0], 'foo')
|
|
367
|
+
})
|
|
368
|
+
|
|
369
|
+
suite('string event:', () => {
|
|
370
|
+
setup(() => {
|
|
371
|
+
log.args.on[5][1]('bar')
|
|
372
|
+
})
|
|
373
|
+
|
|
374
|
+
test('predicate was called once', () => {
|
|
375
|
+
assert.strictEqual(log.counts.predicate, 2)
|
|
376
|
+
})
|
|
377
|
+
|
|
378
|
+
test('predicate was called correctly', () => {
|
|
379
|
+
assert.strictEqual(log.args.predicate[1][0], 1)
|
|
380
|
+
assert.strictEqual(log.args.predicate[1][1], 'bar')
|
|
381
|
+
assert.strictEqual(log.args.predicate[1][2], 1)
|
|
382
|
+
})
|
|
383
|
+
|
|
384
|
+
test('results.push was called once', () => {
|
|
385
|
+
assert.strictEqual(log.counts.push, 2)
|
|
386
|
+
})
|
|
387
|
+
|
|
388
|
+
test('results.push was called correctly', () => {
|
|
389
|
+
assert.strictEqual(log.args.push[1][0], 'bar')
|
|
390
|
+
})
|
|
391
|
+
})
|
|
392
|
+
|
|
393
|
+
suite('array event:', () => {
|
|
394
|
+
setup(() => {
|
|
395
|
+
log.args.on[0][1]()
|
|
396
|
+
})
|
|
397
|
+
|
|
398
|
+
test('predicate was not called', () => {
|
|
399
|
+
assert.strictEqual(log.counts.predicate, 1)
|
|
400
|
+
})
|
|
401
|
+
|
|
402
|
+
test('results.push was not called', () => {
|
|
403
|
+
assert.strictEqual(log.counts.push, 1)
|
|
404
|
+
})
|
|
405
|
+
|
|
406
|
+
suite('endArray event:', () => {
|
|
407
|
+
setup(() => {
|
|
408
|
+
log.args.on[3][1]()
|
|
409
|
+
})
|
|
410
|
+
|
|
411
|
+
test('predicate was called once', () => {
|
|
412
|
+
assert.strictEqual(log.counts.predicate, 2)
|
|
413
|
+
})
|
|
414
|
+
|
|
415
|
+
test('predicate was called correctly', () => {
|
|
416
|
+
assert.strictEqual(log.args.predicate[1][0], 1)
|
|
417
|
+
assert.deepEqual(log.args.predicate[1][1], [])
|
|
418
|
+
assert.strictEqual(log.args.predicate[1][2], 1)
|
|
419
|
+
})
|
|
420
|
+
|
|
421
|
+
test('results.push was called once', () => {
|
|
422
|
+
assert.strictEqual(log.counts.push, 2)
|
|
423
|
+
})
|
|
424
|
+
|
|
425
|
+
test('results.push was called correctly', () => {
|
|
426
|
+
assert.deepEqual(log.args.push[1][0], [])
|
|
427
|
+
})
|
|
428
|
+
|
|
429
|
+
suite('endArray event:', () => {
|
|
430
|
+
setup(() => {
|
|
431
|
+
log.args.on[3][1]()
|
|
432
|
+
})
|
|
433
|
+
|
|
434
|
+
test('predicate was called once', () => {
|
|
435
|
+
assert.strictEqual(log.counts.predicate, 3)
|
|
436
|
+
})
|
|
437
|
+
|
|
438
|
+
test('predicate was called correctly', () => {
|
|
439
|
+
assert.isUndefined(log.args.predicate[2][0])
|
|
440
|
+
assert.deepEqual(log.args.predicate[2][1], [ 'foo', [] ])
|
|
441
|
+
assert.strictEqual(log.args.predicate[2][2], 0)
|
|
442
|
+
})
|
|
443
|
+
|
|
444
|
+
test('results.push was called once', () => {
|
|
445
|
+
assert.strictEqual(log.counts.push, 3)
|
|
446
|
+
})
|
|
447
|
+
|
|
448
|
+
test('results.push was called correctly', () => {
|
|
449
|
+
assert.deepEqual(log.args.push[2][0], [ 'foo', [] ])
|
|
450
|
+
})
|
|
451
|
+
|
|
452
|
+
test('EventEmitter.pause was not called', () => {
|
|
453
|
+
assert.strictEqual(log.counts.pause, 0)
|
|
454
|
+
})
|
|
455
|
+
})
|
|
456
|
+
})
|
|
457
|
+
})
|
|
458
|
+
|
|
459
|
+
suite('object event:', () => {
|
|
460
|
+
setup(() => {
|
|
461
|
+
log.args.on[1][1]()
|
|
462
|
+
})
|
|
463
|
+
|
|
464
|
+
test('results.push was not called', () => {
|
|
465
|
+
assert.strictEqual(log.counts.push, 1)
|
|
466
|
+
})
|
|
467
|
+
|
|
468
|
+
suite('property event:', () => {
|
|
469
|
+
setup(() => {
|
|
470
|
+
log.args.on[2][1]('bar')
|
|
471
|
+
})
|
|
472
|
+
|
|
473
|
+
test('predicate was not called', () => {
|
|
474
|
+
assert.strictEqual(log.counts.predicate, 1)
|
|
475
|
+
})
|
|
476
|
+
|
|
477
|
+
test('results.push was not called', () => {
|
|
478
|
+
assert.strictEqual(log.counts.push, 1)
|
|
479
|
+
})
|
|
480
|
+
|
|
481
|
+
suite('string event:', () => {
|
|
482
|
+
setup(() => {
|
|
483
|
+
log.args.on[5][1]('baz')
|
|
484
|
+
})
|
|
485
|
+
|
|
486
|
+
test('predicate was called once', () => {
|
|
487
|
+
assert.strictEqual(log.counts.predicate, 2)
|
|
488
|
+
})
|
|
489
|
+
|
|
490
|
+
test('predicate was called correctly', () => {
|
|
491
|
+
assert.strictEqual(log.args.predicate[1][0], 'bar')
|
|
492
|
+
assert.strictEqual(log.args.predicate[1][1], 'baz')
|
|
493
|
+
assert.strictEqual(log.args.predicate[1][2], 2)
|
|
494
|
+
})
|
|
495
|
+
|
|
496
|
+
test('results.push was called once', () => {
|
|
497
|
+
assert.strictEqual(log.counts.push, 2)
|
|
498
|
+
})
|
|
499
|
+
|
|
500
|
+
test('results.push was called correctly', () => {
|
|
501
|
+
assert.strictEqual(log.args.push[1][0], 'baz')
|
|
502
|
+
})
|
|
503
|
+
|
|
504
|
+
suite('property event:', () => {
|
|
505
|
+
setup(() => {
|
|
506
|
+
log.args.on[2][1]('nested')
|
|
507
|
+
})
|
|
508
|
+
|
|
509
|
+
test('results.push was not called', () => {
|
|
510
|
+
assert.strictEqual(log.counts.push, 2)
|
|
511
|
+
})
|
|
512
|
+
|
|
513
|
+
suite('object event:', () => {
|
|
514
|
+
setup(() => {
|
|
515
|
+
log.args.on[1][1]()
|
|
516
|
+
})
|
|
517
|
+
|
|
518
|
+
test('predicate was not called', () => {
|
|
519
|
+
assert.strictEqual(log.counts.predicate, 2)
|
|
520
|
+
})
|
|
521
|
+
|
|
522
|
+
test('results.push was not called', () => {
|
|
523
|
+
assert.strictEqual(log.counts.push, 2)
|
|
524
|
+
})
|
|
525
|
+
|
|
526
|
+
suite('endObject event:', () => {
|
|
527
|
+
setup(() => {
|
|
528
|
+
log.args.on[4][1]()
|
|
529
|
+
})
|
|
530
|
+
|
|
531
|
+
test('predicate was called once', () => {
|
|
532
|
+
assert.strictEqual(log.counts.predicate, 3)
|
|
533
|
+
})
|
|
534
|
+
|
|
535
|
+
test('predicate was called correctly', () => {
|
|
536
|
+
assert.strictEqual(log.args.predicate[2][0], 'nested')
|
|
537
|
+
assert.deepEqual(log.args.predicate[2][1], {})
|
|
538
|
+
assert.strictEqual(log.args.predicate[2][2], 2)
|
|
539
|
+
})
|
|
540
|
+
|
|
541
|
+
test('results.push was called once', () => {
|
|
542
|
+
assert.strictEqual(log.counts.push, 3)
|
|
543
|
+
})
|
|
544
|
+
|
|
545
|
+
test('results.push was called correctly', () => {
|
|
546
|
+
assert.deepEqual(log.args.push[2][0], {})
|
|
547
|
+
})
|
|
548
|
+
|
|
549
|
+
suite('endObject event:', () => {
|
|
550
|
+
setup(() => {
|
|
551
|
+
log.args.on[4][1]()
|
|
552
|
+
})
|
|
553
|
+
|
|
554
|
+
test('predicate was called once', () => {
|
|
555
|
+
assert.strictEqual(log.counts.predicate, 4)
|
|
556
|
+
})
|
|
557
|
+
|
|
558
|
+
test('predicate was called correctly', () => {
|
|
559
|
+
assert.strictEqual(log.args.predicate[3][0], 1)
|
|
560
|
+
assert.deepEqual(log.args.predicate[3][1], { bar: 'baz', nested: {} })
|
|
561
|
+
assert.strictEqual(log.args.predicate[3][2], 1)
|
|
562
|
+
})
|
|
563
|
+
|
|
564
|
+
test('results.push was called once', () => {
|
|
565
|
+
assert.strictEqual(log.counts.push, 4)
|
|
566
|
+
})
|
|
567
|
+
|
|
568
|
+
test('results.push was called correctly', () => {
|
|
569
|
+
assert.deepEqual(log.args.push[3][0], { bar: 'baz', nested: {} })
|
|
570
|
+
})
|
|
571
|
+
|
|
572
|
+
test('EventEmitter.pause was not called', () => {
|
|
573
|
+
assert.strictEqual(log.counts.pause, 0)
|
|
574
|
+
})
|
|
575
|
+
})
|
|
576
|
+
})
|
|
577
|
+
})
|
|
578
|
+
})
|
|
579
|
+
})
|
|
580
|
+
})
|
|
581
|
+
})
|
|
582
|
+
})
|
|
583
|
+
|
|
584
|
+
suite('string events, push returns false:', () => {
|
|
585
|
+
setup(() => {
|
|
586
|
+
results.push[0] = false
|
|
587
|
+
log.args.on[5][1]('foo')
|
|
588
|
+
log.args.on[5][1]('bar')
|
|
589
|
+
})
|
|
590
|
+
|
|
591
|
+
teardown(() => {
|
|
592
|
+
results.push[0] = true
|
|
593
|
+
})
|
|
594
|
+
|
|
595
|
+
test('predicate was called twice', () => {
|
|
596
|
+
assert.strictEqual(log.counts.predicate, 2)
|
|
597
|
+
})
|
|
598
|
+
|
|
599
|
+
test('results.push was called once', () => {
|
|
600
|
+
assert.strictEqual(log.counts.push, 1)
|
|
601
|
+
})
|
|
602
|
+
|
|
603
|
+
test('results.push was called correctly', () => {
|
|
604
|
+
assert.strictEqual(log.args.push[0][0], 'foo')
|
|
605
|
+
})
|
|
606
|
+
|
|
607
|
+
test('emitter.pause was called once', () => {
|
|
608
|
+
assert.strictEqual(log.counts.pause, 1)
|
|
609
|
+
assert.strictEqual(log.these.pause[0], results.walk[0])
|
|
610
|
+
})
|
|
611
|
+
|
|
612
|
+
test('emitter.pause was called correctly', () => {
|
|
613
|
+
assert.lengthOf(log.args.pause[0], 0)
|
|
614
|
+
})
|
|
615
|
+
|
|
616
|
+
test('resume was not called', () => {
|
|
617
|
+
assert.strictEqual(log.counts.resume, 0)
|
|
618
|
+
})
|
|
619
|
+
|
|
620
|
+
suite('read stream:', () => {
|
|
621
|
+
setup(() => {
|
|
622
|
+
log.args.DataStream[0][0]()
|
|
623
|
+
})
|
|
624
|
+
|
|
625
|
+
test('resume was called once', () => {
|
|
626
|
+
assert.strictEqual(log.counts.resume, 1)
|
|
627
|
+
assert.isUndefined(log.these.resume[0])
|
|
628
|
+
})
|
|
629
|
+
|
|
630
|
+
test('resume was called correctly', () => {
|
|
631
|
+
assert.lengthOf(log.args.resume[0], 0)
|
|
632
|
+
})
|
|
633
|
+
|
|
634
|
+
test('results.push was called once', () => {
|
|
635
|
+
assert.strictEqual(log.counts.push, 2)
|
|
636
|
+
})
|
|
637
|
+
|
|
638
|
+
test('results.push was called correctly', () => {
|
|
639
|
+
assert.strictEqual(log.args.push[1][0], 'bar')
|
|
640
|
+
})
|
|
641
|
+
})
|
|
642
|
+
})
|
|
643
|
+
})
|
|
644
|
+
|
|
645
|
+
suite('all events then read:', () => {
|
|
646
|
+
setup(() => {
|
|
647
|
+
log.args.on[1][1]()
|
|
648
|
+
log.args.on[2][1]('foo')
|
|
649
|
+
log.args.on[5][1]('bar')
|
|
650
|
+
log.args.on[4][1]()
|
|
651
|
+
log.args.on[5][1]('')
|
|
652
|
+
log.args.on[6][1](0)
|
|
653
|
+
log.args.on[7][1](null)
|
|
654
|
+
log.args.on[7][1](false)
|
|
655
|
+
log.args.on[3][1]()
|
|
656
|
+
log.args.on[8][1]()
|
|
657
|
+
log.args.DataStream[0][0]()
|
|
658
|
+
})
|
|
659
|
+
|
|
660
|
+
test('predicate was called six times', () => {
|
|
661
|
+
assert.strictEqual(log.counts.predicate, 6)
|
|
662
|
+
})
|
|
663
|
+
|
|
664
|
+
test('predicate was called correctly first time', () => {
|
|
665
|
+
assert.strictEqual(log.args.predicate[0][0], 'foo')
|
|
666
|
+
assert.strictEqual(log.args.predicate[0][1], 'bar')
|
|
667
|
+
assert.strictEqual(log.args.predicate[0][2], 2)
|
|
668
|
+
})
|
|
669
|
+
|
|
670
|
+
test('predicate was called correctly second time', () => {
|
|
671
|
+
assert.strictEqual(log.args.predicate[1][0], 0)
|
|
672
|
+
assert.deepEqual(log.args.predicate[1][1], { foo: 'bar' })
|
|
673
|
+
assert.strictEqual(log.args.predicate[1][2], 1)
|
|
674
|
+
})
|
|
675
|
+
|
|
676
|
+
test('predicate was called correctly third time', () => {
|
|
677
|
+
assert.strictEqual(log.args.predicate[2][0], 1)
|
|
678
|
+
assert.strictEqual(log.args.predicate[2][1], '')
|
|
679
|
+
assert.strictEqual(log.args.predicate[2][2], 1)
|
|
680
|
+
})
|
|
681
|
+
|
|
682
|
+
test('predicate was called correctly fourth time', () => {
|
|
683
|
+
assert.strictEqual(log.args.predicate[3][0], 2)
|
|
684
|
+
assert.strictEqual(log.args.predicate[3][1], 0)
|
|
685
|
+
assert.strictEqual(log.args.predicate[3][2], 1)
|
|
686
|
+
})
|
|
687
|
+
|
|
688
|
+
test('predicate was called correctly fifth time', () => {
|
|
689
|
+
assert.strictEqual(log.args.predicate[4][0], 4)
|
|
690
|
+
assert.strictEqual(log.args.predicate[4][1], false)
|
|
691
|
+
assert.strictEqual(log.args.predicate[4][2], 1)
|
|
692
|
+
})
|
|
693
|
+
|
|
694
|
+
test('predicate was called correctly sixth time', () => {
|
|
695
|
+
assert.isUndefined(log.args.predicate[5][0])
|
|
696
|
+
assert.deepEqual(log.args.predicate[5][1], [ { foo: 'bar' }, '', 0, null, false ])
|
|
697
|
+
assert.strictEqual(log.args.predicate[5][2], 0)
|
|
698
|
+
})
|
|
699
|
+
|
|
700
|
+
test('results.push was called seven times', () => {
|
|
701
|
+
assert.strictEqual(log.counts.push, 7)
|
|
702
|
+
})
|
|
703
|
+
|
|
704
|
+
test('results.push was called correctly', () => {
|
|
705
|
+
assert.strictEqual(log.args.push[0][0], 'bar')
|
|
706
|
+
assert.deepEqual(log.args.push[1][0], { foo: 'bar' })
|
|
707
|
+
assert.strictEqual(log.args.push[2][0], '')
|
|
708
|
+
assert.strictEqual(log.args.push[3][0], 0)
|
|
709
|
+
assert.strictEqual(log.args.push[4][0], false)
|
|
710
|
+
assert.deepEqual(log.args.push[5][0], [ { foo: 'bar' }, '', 0, null, false ])
|
|
711
|
+
assert.isNull(log.args.push[6][0])
|
|
712
|
+
})
|
|
713
|
+
|
|
714
|
+
test('results.emit was not called', () => {
|
|
715
|
+
assert.strictEqual(log.counts.emit, 0)
|
|
716
|
+
})
|
|
717
|
+
})
|
|
718
|
+
})
|
|
719
|
+
|
|
720
|
+
suite('read then all events:', () => {
|
|
721
|
+
setup(() => {
|
|
722
|
+
log.args.DataStream[0][0]()
|
|
723
|
+
log.args.on[0][1]()
|
|
724
|
+
log.args.on[1][1]()
|
|
725
|
+
log.args.on[2][1]('foo')
|
|
726
|
+
log.args.on[5][1]('bar')
|
|
727
|
+
log.args.on[4][1]()
|
|
728
|
+
log.args.on[5][1]('')
|
|
729
|
+
log.args.on[6][1](0)
|
|
730
|
+
log.args.on[7][1](null)
|
|
731
|
+
log.args.on[7][1](false)
|
|
732
|
+
log.args.on[3][1]()
|
|
733
|
+
log.args.on[8][1]()
|
|
734
|
+
})
|
|
735
|
+
|
|
736
|
+
test('results.push was called seven times', () => {
|
|
737
|
+
assert.strictEqual(log.counts.push, 7)
|
|
738
|
+
})
|
|
739
|
+
|
|
740
|
+
test('results.push was called correctly', () => {
|
|
741
|
+
assert.strictEqual(log.args.push[0][0], 'bar')
|
|
742
|
+
assert.deepEqual(log.args.push[1][0], { foo: 'bar' })
|
|
743
|
+
assert.strictEqual(log.args.push[2][0], '')
|
|
744
|
+
assert.strictEqual(log.args.push[3][0], 0)
|
|
745
|
+
assert.strictEqual(log.args.push[4][0], false)
|
|
746
|
+
assert.deepEqual(log.args.push[5][0], [ { foo: 'bar' }, '', 0, null, false ])
|
|
747
|
+
assert.isNull(log.args.push[6][0])
|
|
748
|
+
})
|
|
749
|
+
|
|
750
|
+
test('results.emit was not called', () => {
|
|
751
|
+
assert.strictEqual(log.counts.emit, 0)
|
|
752
|
+
})
|
|
753
|
+
})
|
|
754
|
+
})
|
|
755
|
+
|
|
756
|
+
suite('match with predicate returning false:', () => {
|
|
757
|
+
let stream, predicate, options, result
|
|
758
|
+
|
|
759
|
+
setup(() => {
|
|
760
|
+
predicate = spooks.fn({ name: 'predicate', log, results: [ false ] })
|
|
761
|
+
result = match({}, predicate, {})
|
|
762
|
+
})
|
|
763
|
+
|
|
764
|
+
test('DataStream was called once', () => {
|
|
765
|
+
assert.strictEqual(log.counts.DataStream, 1)
|
|
766
|
+
})
|
|
767
|
+
|
|
768
|
+
test('walk was called once', () => {
|
|
769
|
+
assert.strictEqual(log.counts.walk, 1)
|
|
770
|
+
})
|
|
771
|
+
|
|
772
|
+
test('EventEmitter.on was called eleven times', () => {
|
|
773
|
+
assert.strictEqual(log.counts.on, 11)
|
|
774
|
+
})
|
|
775
|
+
|
|
776
|
+
suite('read events:', () => {
|
|
777
|
+
setup(() => {
|
|
778
|
+
log.args.DataStream[0][0]()
|
|
779
|
+
log.args.on[0][1]()
|
|
780
|
+
log.args.on[1][1]()
|
|
781
|
+
log.args.on[2][1]('foo')
|
|
782
|
+
log.args.on[5][1]('bar')
|
|
783
|
+
log.args.on[4][1]()
|
|
784
|
+
log.args.on[5][1]('baz')
|
|
785
|
+
log.args.on[6][1](1)
|
|
786
|
+
log.args.on[7][1](true)
|
|
787
|
+
log.args.on[3][1]()
|
|
788
|
+
log.args.on[8][1]()
|
|
789
|
+
})
|
|
790
|
+
|
|
791
|
+
test('results.push was called once', () => {
|
|
792
|
+
assert.strictEqual(log.counts.push, 1)
|
|
793
|
+
})
|
|
794
|
+
|
|
795
|
+
test('results.push was called correctly', () => {
|
|
796
|
+
assert.isNull(log.args.push[0][0])
|
|
797
|
+
})
|
|
798
|
+
|
|
799
|
+
test('results.emit was not called', () => {
|
|
800
|
+
assert.strictEqual(log.counts.emit, 0)
|
|
801
|
+
})
|
|
802
|
+
})
|
|
803
|
+
})
|
|
804
|
+
|
|
805
|
+
suite('match with string:', () => {
|
|
806
|
+
let stream, options, result
|
|
807
|
+
|
|
808
|
+
setup(() => {
|
|
809
|
+
result = match({}, 'foo', {})
|
|
810
|
+
})
|
|
811
|
+
|
|
812
|
+
test('DataStream was called once', () => {
|
|
813
|
+
assert.strictEqual(log.counts.DataStream, 1)
|
|
814
|
+
})
|
|
815
|
+
|
|
816
|
+
test('walk was called once', () => {
|
|
817
|
+
assert.strictEqual(log.counts.walk, 1)
|
|
818
|
+
})
|
|
819
|
+
|
|
820
|
+
test('EventEmitter.on was called eleven times', () => {
|
|
821
|
+
assert.strictEqual(log.counts.on, 11)
|
|
822
|
+
})
|
|
823
|
+
|
|
824
|
+
suite('read events:', () => {
|
|
825
|
+
setup(() => {
|
|
826
|
+
log.args.DataStream[0][0]()
|
|
827
|
+
log.args.on[1][1]()
|
|
828
|
+
log.args.on[2][1]('foo')
|
|
829
|
+
log.args.on[5][1]('bar')
|
|
830
|
+
log.args.on[2][1]('baz')
|
|
831
|
+
log.args.on[5][1]('qux')
|
|
832
|
+
log.args.on[2][1]('foo')
|
|
833
|
+
log.args.on[5][1]('wibble')
|
|
834
|
+
log.args.on[4][1]()
|
|
835
|
+
log.args.on[8][1]()
|
|
836
|
+
})
|
|
837
|
+
|
|
838
|
+
test('results.push was called three times', () => {
|
|
839
|
+
assert.strictEqual(log.counts.push, 3)
|
|
840
|
+
})
|
|
841
|
+
|
|
842
|
+
test('results.push was called correctly first time', () => {
|
|
843
|
+
assert.strictEqual(log.args.push[0][0], 'bar')
|
|
844
|
+
})
|
|
845
|
+
|
|
846
|
+
test('results.push was called correctly second time', () => {
|
|
847
|
+
assert.strictEqual(log.args.push[1][0], 'wibble')
|
|
848
|
+
})
|
|
849
|
+
|
|
850
|
+
test('results.push was called correctly third time', () => {
|
|
851
|
+
assert.isNull(log.args.push[2][0])
|
|
852
|
+
})
|
|
853
|
+
|
|
854
|
+
test('results.emit was not called', () => {
|
|
855
|
+
assert.strictEqual(log.counts.emit, 0)
|
|
856
|
+
})
|
|
857
|
+
})
|
|
858
|
+
})
|
|
859
|
+
|
|
860
|
+
suite('match with regular expression:', () => {
|
|
861
|
+
let stream, options, result
|
|
862
|
+
|
|
863
|
+
setup(() => {
|
|
864
|
+
result = match({}, /oo/, {})
|
|
865
|
+
})
|
|
866
|
+
|
|
867
|
+
test('DataStream was called once', () => {
|
|
868
|
+
assert.strictEqual(log.counts.DataStream, 1)
|
|
869
|
+
})
|
|
870
|
+
|
|
871
|
+
test('walk was called once', () => {
|
|
872
|
+
assert.strictEqual(log.counts.walk, 1)
|
|
873
|
+
})
|
|
874
|
+
|
|
875
|
+
test('EventEmitter.on was called eleven times', () => {
|
|
876
|
+
assert.strictEqual(log.counts.on, 11)
|
|
877
|
+
})
|
|
878
|
+
|
|
879
|
+
suite('read events:', () => {
|
|
880
|
+
setup(() => {
|
|
881
|
+
log.args.DataStream[0][0]()
|
|
882
|
+
log.args.on[1][1]()
|
|
883
|
+
log.args.on[2][1]('foo')
|
|
884
|
+
log.args.on[5][1]('bar')
|
|
885
|
+
log.args.on[2][1]('fo')
|
|
886
|
+
log.args.on[5][1]('baz')
|
|
887
|
+
log.args.on[2][1]('oo')
|
|
888
|
+
log.args.on[5][1]('qux')
|
|
889
|
+
log.args.on[4][1]()
|
|
890
|
+
log.args.on[8][1]()
|
|
891
|
+
})
|
|
892
|
+
|
|
893
|
+
test('results.push was called three times', () => {
|
|
894
|
+
assert.strictEqual(log.counts.push, 3)
|
|
895
|
+
})
|
|
896
|
+
|
|
897
|
+
test('results.push was called correctly first time', () => {
|
|
898
|
+
assert.strictEqual(log.args.push[0][0], 'bar')
|
|
899
|
+
})
|
|
900
|
+
|
|
901
|
+
test('results.push was called correctly second time', () => {
|
|
902
|
+
assert.strictEqual(log.args.push[1][0], 'qux')
|
|
903
|
+
})
|
|
904
|
+
|
|
905
|
+
test('results.push was called correctly third time', () => {
|
|
906
|
+
assert.isNull(log.args.push[2][0])
|
|
907
|
+
})
|
|
908
|
+
|
|
909
|
+
test('results.emit was not called', () => {
|
|
910
|
+
assert.strictEqual(log.counts.emit, 0)
|
|
911
|
+
})
|
|
912
|
+
})
|
|
913
|
+
})
|
|
914
|
+
|
|
915
|
+
suite('match with numbers=true:', () => {
|
|
916
|
+
let stream, options, result
|
|
917
|
+
|
|
918
|
+
setup(() => {
|
|
919
|
+
result = match({}, '1', { numbers: true })
|
|
920
|
+
})
|
|
921
|
+
|
|
922
|
+
test('DataStream was called once', () => {
|
|
923
|
+
assert.strictEqual(log.counts.DataStream, 1)
|
|
924
|
+
})
|
|
925
|
+
|
|
926
|
+
test('walk was called once', () => {
|
|
927
|
+
assert.strictEqual(log.counts.walk, 1)
|
|
928
|
+
})
|
|
929
|
+
|
|
930
|
+
test('EventEmitter.on was called eleven times', () => {
|
|
931
|
+
assert.strictEqual(log.counts.on, 11)
|
|
932
|
+
})
|
|
933
|
+
|
|
934
|
+
suite('read events:', () => {
|
|
935
|
+
setup(() => {
|
|
936
|
+
log.args.DataStream[0][0]()
|
|
937
|
+
log.args.on[1][1]()
|
|
938
|
+
log.args.on[2][1]('0')
|
|
939
|
+
log.args.on[5][1]('foo')
|
|
940
|
+
log.args.on[2][1]('1')
|
|
941
|
+
log.args.on[5][1]('bar')
|
|
942
|
+
log.args.on[2][1]('2')
|
|
943
|
+
log.args.on[0][1]()
|
|
944
|
+
log.args.on[5][1]('baz')
|
|
945
|
+
log.args.on[5][1]('qux')
|
|
946
|
+
log.args.on[3][1]()
|
|
947
|
+
log.args.on[4][1]()
|
|
948
|
+
log.args.on[8][1]()
|
|
949
|
+
})
|
|
950
|
+
|
|
951
|
+
test('results.push was called three times', () => {
|
|
952
|
+
assert.strictEqual(log.counts.push, 3)
|
|
953
|
+
})
|
|
954
|
+
|
|
955
|
+
test('results.push was called correctly first time', () => {
|
|
956
|
+
assert.strictEqual(log.args.push[0][0], 'bar')
|
|
957
|
+
})
|
|
958
|
+
|
|
959
|
+
test('results.push was called correctly second time', () => {
|
|
960
|
+
assert.strictEqual(log.args.push[1][0], 'qux')
|
|
961
|
+
})
|
|
962
|
+
|
|
963
|
+
test('results.push was called correctly third time', () => {
|
|
964
|
+
assert.isNull(log.args.push[2][0])
|
|
965
|
+
})
|
|
966
|
+
|
|
967
|
+
test('results.emit was not called', () => {
|
|
968
|
+
assert.strictEqual(log.counts.emit, 0)
|
|
969
|
+
})
|
|
970
|
+
})
|
|
971
|
+
})
|
|
972
|
+
|
|
973
|
+
suite('match with bufferLength=3:', () => {
|
|
974
|
+
let stream, options, result
|
|
975
|
+
|
|
976
|
+
setup(() => {
|
|
977
|
+
result = match({}, 'foo', { bufferLength: 3 })
|
|
978
|
+
})
|
|
979
|
+
|
|
980
|
+
test('DataStream was called once', () => {
|
|
981
|
+
assert.strictEqual(log.counts.DataStream, 1)
|
|
982
|
+
})
|
|
983
|
+
|
|
984
|
+
test('walk was called once', () => {
|
|
985
|
+
assert.strictEqual(log.counts.walk, 1)
|
|
986
|
+
})
|
|
987
|
+
|
|
988
|
+
test('EventEmitter.on was called eleven times', () => {
|
|
989
|
+
assert.strictEqual(log.counts.on, 11)
|
|
990
|
+
})
|
|
991
|
+
|
|
992
|
+
suite('two matching events:', () => {
|
|
993
|
+
setup(() => {
|
|
994
|
+
log.args.on[1][1]()
|
|
995
|
+
log.args.on[2][1]('foo')
|
|
996
|
+
log.args.on[5][1]('bar')
|
|
997
|
+
log.args.on[2][1]('baz')
|
|
998
|
+
log.args.on[5][1]('qux')
|
|
999
|
+
log.args.on[2][1]('foo')
|
|
1000
|
+
log.args.on[5][1]('wibble')
|
|
1001
|
+
log.args.on[2][1]('foo')
|
|
1002
|
+
})
|
|
1003
|
+
|
|
1004
|
+
test('EventEmitter.pause was not called', () => {
|
|
1005
|
+
assert.strictEqual(log.counts.pause, 0)
|
|
1006
|
+
})
|
|
1007
|
+
|
|
1008
|
+
suite('matching event:', () => {
|
|
1009
|
+
setup(() => {
|
|
1010
|
+
log.args.on[5][1]('blee')
|
|
1011
|
+
})
|
|
1012
|
+
|
|
1013
|
+
test('results.push was not called', () => {
|
|
1014
|
+
assert.strictEqual(log.counts.push, 0)
|
|
1015
|
+
})
|
|
1016
|
+
|
|
1017
|
+
test('EventEmitter.pause was called once', () => {
|
|
1018
|
+
assert.strictEqual(log.counts.pause, 1)
|
|
1019
|
+
})
|
|
1020
|
+
|
|
1021
|
+
test('resume was not called', () => {
|
|
1022
|
+
assert.strictEqual(log.counts.resume, 0)
|
|
1023
|
+
})
|
|
1024
|
+
|
|
1025
|
+
suite('read:', () => {
|
|
1026
|
+
setup(() => {
|
|
1027
|
+
log.args.DataStream[0][0]()
|
|
1028
|
+
})
|
|
1029
|
+
|
|
1030
|
+
test('resume was called once', () => {
|
|
1031
|
+
assert.strictEqual(log.counts.resume, 1)
|
|
1032
|
+
})
|
|
1033
|
+
|
|
1034
|
+
test('results.push was called three times', () => {
|
|
1035
|
+
assert.strictEqual(log.counts.push, 3)
|
|
1036
|
+
})
|
|
1037
|
+
|
|
1038
|
+
test('results.push was called correctly first time', () => {
|
|
1039
|
+
assert.strictEqual(log.args.push[0][0], 'bar')
|
|
1040
|
+
})
|
|
1041
|
+
|
|
1042
|
+
test('results.push was called correctly second time', () => {
|
|
1043
|
+
assert.strictEqual(log.args.push[1][0], 'wibble')
|
|
1044
|
+
})
|
|
1045
|
+
|
|
1046
|
+
test('results.push was called correctly third time', () => {
|
|
1047
|
+
assert.strictEqual(log.args.push[2][0], 'blee')
|
|
1048
|
+
})
|
|
1049
|
+
|
|
1050
|
+
test('results.emit was not called', () => {
|
|
1051
|
+
assert.strictEqual(log.counts.emit, 0)
|
|
1052
|
+
})
|
|
1053
|
+
})
|
|
1054
|
+
})
|
|
1055
|
+
})
|
|
1056
|
+
})
|
|
1057
|
+
})
|
|
1058
|
+
})
|