* Bump the npm group with 11 updates Bumps the npm group with 11 updates: | Package | From | To | | --- | --- | --- | | [@actions/artifact](https://github.com/actions/toolkit/tree/HEAD/packages/artifact) | `1.1.1` | `1.1.2` | | [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) | `1.10.0` | `1.10.1` | | [uuid](https://github.com/uuidjs/uuid) | `9.0.0` | `9.0.1` | | [@types/uuid](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/uuid) | `9.0.3` | `9.0.4` | | [@types/adm-zip](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/adm-zip) | `0.5.0` | `0.5.1` | | [@types/js-yaml](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/js-yaml) | `4.0.5` | `4.0.6` | | [@types/semver](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/semver) | `7.5.1` | `7.5.2` | | [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) | `6.5.0` | `6.7.2` | | [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) | `6.6.0` | `6.7.2` | | [eslint](https://github.com/eslint/eslint) | `8.48.0` | `8.49.0` | | [sinon](https://github.com/sinonjs/sinon) | `15.2.0` | `16.0.0` | Updates `@actions/artifact` from 1.1.1 to 1.1.2 - [Changelog](https://github.com/actions/toolkit/blob/main/packages/artifact/RELEASES.md) - [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/artifact) Updates `@actions/core` from 1.10.0 to 1.10.1 - [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md) - [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core) Updates `uuid` from 9.0.0 to 9.0.1 - [Changelog](https://github.com/uuidjs/uuid/blob/main/CHANGELOG.md) - [Commits](https://github.com/uuidjs/uuid/compare/v9.0.0...v9.0.1) Updates `@types/uuid` from 9.0.3 to 9.0.4 - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/uuid) Updates `@types/adm-zip` from 0.5.0 to 0.5.1 - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/adm-zip) Updates `@types/js-yaml` from 4.0.5 to 4.0.6 - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/js-yaml) Updates `@types/semver` from 7.5.1 to 7.5.2 - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/semver) Updates `@typescript-eslint/eslint-plugin` from 6.5.0 to 6.7.2 - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.7.2/packages/eslint-plugin) Updates `@typescript-eslint/parser` from 6.6.0 to 6.7.2 - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.7.2/packages/parser) Updates `eslint` from 8.48.0 to 8.49.0 - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v8.48.0...v8.49.0) Updates `sinon` from 15.2.0 to 16.0.0 - [Release notes](https://github.com/sinonjs/sinon/releases) - [Changelog](https://github.com/sinonjs/sinon/blob/main/docs/changelog.md) - [Commits](https://github.com/sinonjs/sinon/compare/v15.2.0...v16.0.0) --- updated-dependencies: - dependency-name: "@actions/artifact" dependency-type: direct:production update-type: version-update:semver-patch dependency-group: npm - dependency-name: "@actions/core" dependency-type: direct:production update-type: version-update:semver-patch dependency-group: npm - dependency-name: uuid dependency-type: direct:production update-type: version-update:semver-patch dependency-group: npm - dependency-name: "@types/uuid" dependency-type: direct:production update-type: version-update:semver-patch dependency-group: npm - dependency-name: "@types/adm-zip" dependency-type: direct:development update-type: version-update:semver-patch dependency-group: npm - dependency-name: "@types/js-yaml" dependency-type: direct:development update-type: version-update:semver-patch dependency-group: npm - dependency-name: "@types/semver" dependency-type: direct:development update-type: version-update:semver-patch dependency-group: npm - dependency-name: "@typescript-eslint/eslint-plugin" dependency-type: direct:development update-type: version-update:semver-minor dependency-group: npm - dependency-name: "@typescript-eslint/parser" dependency-type: direct:development update-type: version-update:semver-minor dependency-group: npm - dependency-name: eslint dependency-type: direct:development update-type: version-update:semver-minor dependency-group: npm - dependency-name: sinon dependency-type: direct:development update-type: version-update:semver-major dependency-group: npm ... Signed-off-by: dependabot[bot] <support@github.com> * Update checked-in dependencies --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
288 lines
8.3 KiB
JavaScript
288 lines
8.3 KiB
JavaScript
"use strict";
|
|
|
|
const arrayProto = require("@sinonjs/commons").prototypes.array;
|
|
const isPropertyConfigurable = require("./util/core/is-property-configurable");
|
|
const exportAsyncBehaviors = require("./util/core/export-async-behaviors");
|
|
const extend = require("./util/core/extend");
|
|
|
|
const slice = arrayProto.slice;
|
|
|
|
const useLeftMostCallback = -1;
|
|
const useRightMostCallback = -2;
|
|
|
|
function throwsException(fake, error, message) {
|
|
if (typeof error === "function") {
|
|
fake.exceptionCreator = error;
|
|
} else if (typeof error === "string") {
|
|
fake.exceptionCreator = function () {
|
|
const newException = new Error(
|
|
message || `Sinon-provided ${error}`
|
|
);
|
|
newException.name = error;
|
|
return newException;
|
|
};
|
|
} else if (!error) {
|
|
fake.exceptionCreator = function () {
|
|
return new Error("Error");
|
|
};
|
|
} else {
|
|
fake.exception = error;
|
|
}
|
|
}
|
|
|
|
const defaultBehaviors = {
|
|
callsFake: function callsFake(fake, fn) {
|
|
fake.fakeFn = fn;
|
|
fake.exception = undefined;
|
|
fake.exceptionCreator = undefined;
|
|
},
|
|
|
|
callsArg: function callsArg(fake, index) {
|
|
if (typeof index !== "number") {
|
|
throw new TypeError("argument index is not number");
|
|
}
|
|
|
|
fake.callArgAt = index;
|
|
fake.callbackArguments = [];
|
|
fake.callbackContext = undefined;
|
|
fake.callArgProp = undefined;
|
|
fake.callbackAsync = false;
|
|
},
|
|
|
|
callsArgOn: function callsArgOn(fake, index, context) {
|
|
if (typeof index !== "number") {
|
|
throw new TypeError("argument index is not number");
|
|
}
|
|
|
|
fake.callArgAt = index;
|
|
fake.callbackArguments = [];
|
|
fake.callbackContext = context;
|
|
fake.callArgProp = undefined;
|
|
fake.callbackAsync = false;
|
|
},
|
|
|
|
callsArgWith: function callsArgWith(fake, index) {
|
|
if (typeof index !== "number") {
|
|
throw new TypeError("argument index is not number");
|
|
}
|
|
|
|
fake.callArgAt = index;
|
|
fake.callbackArguments = slice(arguments, 2);
|
|
fake.callbackContext = undefined;
|
|
fake.callArgProp = undefined;
|
|
fake.callbackAsync = false;
|
|
},
|
|
|
|
callsArgOnWith: function callsArgWith(fake, index, context) {
|
|
if (typeof index !== "number") {
|
|
throw new TypeError("argument index is not number");
|
|
}
|
|
|
|
fake.callArgAt = index;
|
|
fake.callbackArguments = slice(arguments, 3);
|
|
fake.callbackContext = context;
|
|
fake.callArgProp = undefined;
|
|
fake.callbackAsync = false;
|
|
},
|
|
|
|
usingPromise: function usingPromise(fake, promiseLibrary) {
|
|
fake.promiseLibrary = promiseLibrary;
|
|
},
|
|
|
|
yields: function (fake) {
|
|
fake.callArgAt = useLeftMostCallback;
|
|
fake.callbackArguments = slice(arguments, 1);
|
|
fake.callbackContext = undefined;
|
|
fake.callArgProp = undefined;
|
|
fake.callbackAsync = false;
|
|
fake.fakeFn = undefined;
|
|
},
|
|
|
|
yieldsRight: function (fake) {
|
|
fake.callArgAt = useRightMostCallback;
|
|
fake.callbackArguments = slice(arguments, 1);
|
|
fake.callbackContext = undefined;
|
|
fake.callArgProp = undefined;
|
|
fake.callbackAsync = false;
|
|
fake.fakeFn = undefined;
|
|
},
|
|
|
|
yieldsOn: function (fake, context) {
|
|
fake.callArgAt = useLeftMostCallback;
|
|
fake.callbackArguments = slice(arguments, 2);
|
|
fake.callbackContext = context;
|
|
fake.callArgProp = undefined;
|
|
fake.callbackAsync = false;
|
|
fake.fakeFn = undefined;
|
|
},
|
|
|
|
yieldsTo: function (fake, prop) {
|
|
fake.callArgAt = useLeftMostCallback;
|
|
fake.callbackArguments = slice(arguments, 2);
|
|
fake.callbackContext = undefined;
|
|
fake.callArgProp = prop;
|
|
fake.callbackAsync = false;
|
|
fake.fakeFn = undefined;
|
|
},
|
|
|
|
yieldsToOn: function (fake, prop, context) {
|
|
fake.callArgAt = useLeftMostCallback;
|
|
fake.callbackArguments = slice(arguments, 3);
|
|
fake.callbackContext = context;
|
|
fake.callArgProp = prop;
|
|
fake.callbackAsync = false;
|
|
fake.fakeFn = undefined;
|
|
},
|
|
|
|
throws: throwsException,
|
|
throwsException: throwsException,
|
|
|
|
returns: function returns(fake, value) {
|
|
fake.returnValue = value;
|
|
fake.resolve = false;
|
|
fake.reject = false;
|
|
fake.returnValueDefined = true;
|
|
fake.exception = undefined;
|
|
fake.exceptionCreator = undefined;
|
|
fake.fakeFn = undefined;
|
|
},
|
|
|
|
returnsArg: function returnsArg(fake, index) {
|
|
if (typeof index !== "number") {
|
|
throw new TypeError("argument index is not number");
|
|
}
|
|
|
|
fake.returnArgAt = index;
|
|
},
|
|
|
|
throwsArg: function throwsArg(fake, index) {
|
|
if (typeof index !== "number") {
|
|
throw new TypeError("argument index is not number");
|
|
}
|
|
|
|
fake.throwArgAt = index;
|
|
},
|
|
|
|
returnsThis: function returnsThis(fake) {
|
|
fake.returnThis = true;
|
|
},
|
|
|
|
resolves: function resolves(fake, value) {
|
|
fake.returnValue = value;
|
|
fake.resolve = true;
|
|
fake.resolveThis = false;
|
|
fake.reject = false;
|
|
fake.returnValueDefined = true;
|
|
fake.exception = undefined;
|
|
fake.exceptionCreator = undefined;
|
|
fake.fakeFn = undefined;
|
|
},
|
|
|
|
resolvesArg: function resolvesArg(fake, index) {
|
|
if (typeof index !== "number") {
|
|
throw new TypeError("argument index is not number");
|
|
}
|
|
fake.resolveArgAt = index;
|
|
fake.returnValue = undefined;
|
|
fake.resolve = true;
|
|
fake.resolveThis = false;
|
|
fake.reject = false;
|
|
fake.returnValueDefined = false;
|
|
fake.exception = undefined;
|
|
fake.exceptionCreator = undefined;
|
|
fake.fakeFn = undefined;
|
|
},
|
|
|
|
rejects: function rejects(fake, error, message) {
|
|
let reason;
|
|
if (typeof error === "string") {
|
|
reason = new Error(message || "");
|
|
reason.name = error;
|
|
} else if (!error) {
|
|
reason = new Error("Error");
|
|
} else {
|
|
reason = error;
|
|
}
|
|
fake.returnValue = reason;
|
|
fake.resolve = false;
|
|
fake.resolveThis = false;
|
|
fake.reject = true;
|
|
fake.returnValueDefined = true;
|
|
fake.exception = undefined;
|
|
fake.exceptionCreator = undefined;
|
|
fake.fakeFn = undefined;
|
|
|
|
return fake;
|
|
},
|
|
|
|
resolvesThis: function resolvesThis(fake) {
|
|
fake.returnValue = undefined;
|
|
fake.resolve = false;
|
|
fake.resolveThis = true;
|
|
fake.reject = false;
|
|
fake.returnValueDefined = false;
|
|
fake.exception = undefined;
|
|
fake.exceptionCreator = undefined;
|
|
fake.fakeFn = undefined;
|
|
},
|
|
|
|
callThrough: function callThrough(fake) {
|
|
fake.callsThrough = true;
|
|
},
|
|
|
|
callThroughWithNew: function callThroughWithNew(fake) {
|
|
fake.callsThroughWithNew = true;
|
|
},
|
|
|
|
get: function get(fake, getterFunction) {
|
|
const rootStub = fake.stub || fake;
|
|
|
|
Object.defineProperty(rootStub.rootObj, rootStub.propName, {
|
|
get: getterFunction,
|
|
configurable: isPropertyConfigurable(
|
|
rootStub.rootObj,
|
|
rootStub.propName
|
|
),
|
|
});
|
|
|
|
return fake;
|
|
},
|
|
|
|
set: function set(fake, setterFunction) {
|
|
const rootStub = fake.stub || fake;
|
|
|
|
Object.defineProperty(
|
|
rootStub.rootObj,
|
|
rootStub.propName,
|
|
// eslint-disable-next-line accessor-pairs
|
|
{
|
|
set: setterFunction,
|
|
configurable: isPropertyConfigurable(
|
|
rootStub.rootObj,
|
|
rootStub.propName
|
|
),
|
|
}
|
|
);
|
|
|
|
return fake;
|
|
},
|
|
|
|
value: function value(fake, newVal) {
|
|
const rootStub = fake.stub || fake;
|
|
|
|
Object.defineProperty(rootStub.rootObj, rootStub.propName, {
|
|
value: newVal,
|
|
enumerable: true,
|
|
writable: true,
|
|
configurable:
|
|
rootStub.shadowsPropOnPrototype ||
|
|
isPropertyConfigurable(rootStub.rootObj, rootStub.propName),
|
|
});
|
|
|
|
return fake;
|
|
},
|
|
};
|
|
|
|
const asyncBehaviors = exportAsyncBehaviors(defaultBehaviors);
|
|
|
|
module.exports = extend({}, defaultBehaviors, asyncBehaviors);
|