instance.js 452 B

123456789101112131415161718
  1. var assert = require('assert');
  2. var Traverse = require('traverse');
  3. var EventEmitter = require('events').EventEmitter;
  4. exports['check instanceof on node elems'] = function () {
  5. var counts = { emitter : 0 };
  6. Traverse([ new EventEmitter, 3, 4, { ev : new EventEmitter }])
  7. .forEach(function (node) {
  8. if (node instanceof EventEmitter) counts.emitter ++;
  9. })
  10. ;
  11. assert.equal(counts.emitter, 2);
  12. };