Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@contract-case/case-core-plugin-function

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@contract-case/case-core-plugin-function - npm Package Compare versions

Comparing version 0.17.1 to 0.18.0

10

dist/package.json
{
"name": "@contract-case/case-core-plugin-function",
"version": "0.17.1",
"version": "0.18.0",
"description": "ContractCase core function plugin, allowing validation of arbitrary functions",

@@ -58,3 +58,3 @@ "keywords": [

"rimraf": "^6.0.1",
"ts-jest": "^29.1.5",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",

@@ -64,6 +64,6 @@ "typescript": "5.5.4"

"dependencies": {
"@contract-case/case-core-plugin-function-dsl": "^0.17.1",
"@contract-case/case-plugin-base": "^0.17.1",
"@contract-case/case-plugin-dsl-types": "^0.17.1"
"@contract-case/case-core-plugin-function-dsl": "^0.18.0",
"@contract-case/case-plugin-base": "^0.18.0",
"@contract-case/case-plugin-dsl-types": "^0.18.0"
}
}

@@ -17,4 +17,5 @@ "use strict";

'_case:mock:type': case_core_plugin_function_dsl_1.MOCK_FUNCTION_CALLER,
variables: context['_case:currentRun:context:variables'],
functionHandle,
stateVariables: context['_case:currentRun:context:variables'],
functions: {},
mock: { functionHandle },
},

@@ -21,0 +22,0 @@ assertableData: () => Promise.resolve().then(async () => {

import { MockFunctionDescriptor, MOCK_FUNCTION_EXECUTION } from '@contract-case/case-core-plugin-function-dsl';
import { MatchContext, MockData } from '@contract-case/case-plugin-base';
import { AllSetup } from './types';
export declare const setupMockFunctionExecution: ({ request: expectedArguments, response: returnValue }: MockFunctionDescriptor, parentContext: MatchContext) => Promise<MockData<AllSetup, typeof MOCK_FUNCTION_EXECUTION>>;
export declare const setupMockFunctionExecution: ({ request: expectedArguments, response: returnValue, functionName, }: MockFunctionDescriptor, parentContext: MatchContext) => Promise<MockData<AllSetup, typeof MOCK_FUNCTION_EXECUTION>>;
//# sourceMappingURL=mockFunctionExecution.d.ts.map

@@ -6,11 +6,20 @@ "use strict";

const case_plugin_base_1 = require("@contract-case/case-plugin-base");
const setupMockFunctionExecution = ({ request: expectedArguments, response: returnValue }, parentContext) => Promise.resolve((0, case_plugin_base_1.addLocation)('mockFunction', parentContext)).then((context) => {
const setupMockFunctionExecution = ({ request: expectedArguments, response: returnValue, functionName, }, parentContext) => Promise.resolve((0, case_plugin_base_1.addLocation)(`mockFunction[${functionName}]`, parentContext)).then((context) => {
// create mock function
let data = null;
const f = (...actualArguments) => {
data = { actualArguments };
context.logger.debug('Mock function was invoked with arguments:', actualArguments);
const f = (...stringArgs) => {
data = {
actualArguments: stringArgs.map((s, index) => {
try {
return JSON.parse(s);
}
catch (e) {
throw new case_plugin_base_1.CaseConfigurationError(`Parsing error in argument number ${index} in function '${functionName}': ${e.message}\n The argument was: ${s}`);
}
}),
};
context.logger.debug('Mock function was invoked with arguments:', data.actualArguments);
const strippedReturnValue = context.descendAndStrip(returnValue, (0, case_plugin_base_1.addLocation)('returnValue', context));
context.logger.debug('Returning', strippedReturnValue);
return strippedReturnValue;
return JSON.stringify(strippedReturnValue);
};

@@ -20,4 +29,5 @@ return {

'_case:mock:type': case_core_plugin_function_dsl_1.MOCK_FUNCTION_EXECUTION,
variables: context['_case:currentRun:context:variables'],
invokeable: f,
stateVariables: context['_case:currentRun:context:variables'],
functions: { [functionName]: f },
mock: { functionHandle: functionName },
},

@@ -24,0 +34,0 @@ assertableData: () => Promise.resolve(data).then((result) => {

{
"name": "@contract-case/case-core-plugin-function",
"version": "0.17.1",
"version": "0.18.0",
"description": "ContractCase core function plugin, allowing validation of arbitrary functions",

@@ -58,3 +58,3 @@ "keywords": [

"rimraf": "^6.0.1",
"ts-jest": "^29.1.5",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",

@@ -64,7 +64,7 @@ "typescript": "5.5.4"

"dependencies": {
"@contract-case/case-core-plugin-function-dsl": "^0.17.1",
"@contract-case/case-plugin-base": "^0.17.1",
"@contract-case/case-plugin-dsl-types": "^0.17.1"
"@contract-case/case-core-plugin-function-dsl": "^0.18.0",
"@contract-case/case-plugin-base": "^0.18.0",
"@contract-case/case-plugin-dsl-types": "^0.18.0"
},
"gitHead": "0fdf25453a567bc6433834374725954e3d2ff206"
"gitHead": "9d63acd9233bdfcf1d0933517547faedaa6dc860"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc