How to use @sinonjs/samsam - 10 common examples

To help you get started, we’ve selected a few @sinonjs/samsam examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sinonjs / sinon / lib / sinon / spy-formatters.js View on Github external
D: function(spyInstance, args) {
        var message = "";

        for (var i = 0, l = spyInstance.callCount; i < l; ++i) {
            // describe multiple calls
            if (l > 1) {
                message += "\nCall " + (i + 1) + ":";
            }
            var calledArgs = spyInstance.getCall(i).args;
            for (var j = 0; j < calledArgs.length || j < args.length; ++j) {
                message += "\n";
                var calledArgMessage = j < calledArgs.length ? sinonFormat(calledArgs[j]) : "";
                if (match.isMatcher(args[j])) {
                    message += colorSinonMatchText(args[j], calledArgs[j], calledArgMessage);
                } else {
                    var expectedArgMessage = j < args.length ? sinonFormat(args[j]) : "";
                    var diff = jsDiff.diffJson(calledArgMessage, expectedArgMessage);
                    message += colorDiffText(diff);
                }
            }
        }

        return message;
    },
github sinonjs / formatio / lib / formatio.js View on Github external
function getSymbols(object) {
    if (samsam.isArguments(object)) {
        return [];
    }

    /* istanbul ignore else */
    if (typeof Object.getOwnPropertySymbols === "function") {
        return Object.getOwnPropertySymbols(object);
    }

    /* istanbul ignore next: This is only for IE, since getOwnPropertySymbols
     * does not exist on Object there
     */
    return [];
}
github sinonjs / sinon / lib / sinon / mock-expectation.js View on Github external
function verifyMatcher(possibleMatcher, arg) {
    var isMatcher = match.isMatcher(possibleMatcher);

    return (isMatcher && possibleMatcher.test(arg)) || true;
}
github sinonjs / sinon / lib / sinon / proxy-call.js View on Github external
calledOn: function calledOn(thisValue) {
        if (match.isMatcher(thisValue)) {
            return thisValue.test(this.thisValue);
        }
        return this.thisValue === thisValue;
    },
github sinonjs / sinon / lib / sinon / assert.js View on Github external
match: function match(actual, expectation) {
        var matcher = createMatcher(expectation);
        if (matcher.test(actual)) {
            assert.pass("match");
        } else {
            var formatted = [
                "expected value to match",
                "    expected = " + format(expectation),
                "    actual = " + format(actual)
            ];

            failAssertion(this, join(formatted, "\n"));
        }
    }
};
github sinonjs / sinon / lib / sinon / proxy-call.js View on Github external
function(prev, expectation, i) {
                var actual = self.args[i];

                return prev && match(expectation).test(actual);
            },
            true
github sinonjs / sinon / lib / sinon / proxy-call.js View on Github external
returned: function returned(value) {
        return deepEqual(this.returnValue, value);
    },
github sinonjs / sinon / lib / sinon / mock.js View on Github external
return every(arr1, function(element, i) {
        return deepEqual(arr2[i], element);
    });
}
github sinonjs / sinon / lib / sinon / proxy-call.js View on Github external
function(prev, arg, i) {
                return prev && deepEqual(self.args[i], arg);
            },
            true
github sinonjs / sinon / lib / sinon / spy.js View on Github external
function matches(fake, args, strict) {
    var margs = fake.matchingArguments;
    if (margs.length <= args.length && deepEqual(slice(args, 0, margs.length), margs)) {
        return !strict || margs.length === args.length;
    }
    return false;
}

@sinonjs/samsam

Value identification and comparison functions

BSD-3-Clause
Latest version published 3 months ago

Package Health Score

85 / 100
Full package analysis

Similar packages