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