Sha256: 391d1b55e2dac8b19a22c25d063601e8d5973707563b697547b1b9722133e338

Contents?: true

Size: 928 Bytes

Versions: 80

Compression:

Stored size: 928 Bytes

Contents

var assert = require('assert');

var mustCallChecks = [];

function runCallChecks() {
  var failed_count = 0;
  for (var i=0 ; i< mustCallChecks.length; ++i) {
    var context = mustCallChecks[i];
    if (context.actual === context.expected) {
      continue;
    }

    failed_count++;
    console.log('Mismatched %s function calls. Expected %d, actual %d.',
                context.name,
                context.expected,
                context.actual);
    console.log(context.stack.split('\n').slice(2).join('\n'));
  }

  assert(failed_count === 0);
}

after(runCallChecks);

exports.mustCall = function(fn, expected) {
  if (typeof expected !== 'number') expected = 1;

  var context = {
    expected: expected,
    actual: 0,
    stack: (new Error).stack,
    name: fn.name || '<anonymous>'
  };

  mustCallChecks.push(context);

  return function() {
    context.actual++;
    return fn.apply(this, arguments);
  };
};

Version data entries

80 entries across 80 versions & 10 rubygems

Version Path
smock-0.1.225 node_modules/webpack/node_modules/node-libs-browser/node_modules/events/tests/common.js
smock-0.1.224 node_modules/webpack/node_modules/node-libs-browser/node_modules/events/tests/common.js
smock-0.1.9 node_modules/webpack/node_modules/node-libs-browser/node_modules/events/tests/common.js
smock-0.1.223 node_modules/webpack/node_modules/node-libs-browser/node_modules/events/tests/common.js
smock-0.1.222 node_modules/webpack/node_modules/node-libs-browser/node_modules/events/tests/common.js
smock-0.1.221 node_modules/webpack/node_modules/node-libs-browser/node_modules/events/tests/common.js
smock-0.1.220 node_modules/webpack/node_modules/node-libs-browser/node_modules/events/tests/common.js
smock-0.1.219 node_modules/webpack/node_modules/node-libs-browser/node_modules/events/tests/common.js
smock-0.1.218 node_modules/webpack/node_modules/node-libs-browser/node_modules/events/tests/common.js
smock-0.1.217 node_modules/webpack/node_modules/node-libs-browser/node_modules/events/tests/common.js
smock-0.1.216 node_modules/webpack/node_modules/node-libs-browser/node_modules/events/tests/common.js
smock-0.1.215 node_modules/webpack/node_modules/node-libs-browser/node_modules/events/tests/common.js
smock-0.1.214 node_modules/webpack/node_modules/node-libs-browser/node_modules/events/tests/common.js
smock-0.1.213 node_modules/webpack/node_modules/node-libs-browser/node_modules/events/tests/common.js
smock-0.1.212 node_modules/webpack/node_modules/node-libs-browser/node_modules/events/tests/common.js
smock-0.1.211 node_modules/webpack/node_modules/node-libs-browser/node_modules/events/tests/common.js
smock-0.1.210 node_modules/webpack/node_modules/node-libs-browser/node_modules/events/tests/common.js
smock-0.1.209 node_modules/webpack/node_modules/node-libs-browser/node_modules/events/tests/common.js
smock-0.1.208 node_modules/webpack/node_modules/node-libs-browser/node_modules/events/tests/common.js
sprockets-browserify-0.3.0 node_modules/browserify/node_modules/events/tests/common.js