You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

node-execution-context

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-execution-context - npm Package Compare versions

Comparing version

to
1.1.4

2

package.json
{
"name": "node-execution-context",
"version": "1.1.3",
"version": "1.1.4",
"description": "Provides execution context wrapper for node JS, can be used to create execution wrapper for handling requests and more",

@@ -5,0 +5,0 @@ "author": "Oded Goldglas <odedglas@gmail.com>",

@@ -61,3 +61,3 @@ const { isUndefined } = require('../lib');

if (!children.length) {
executionContextMap.delete(ref)
suspend(() => executionContextMap.delete(ref));

@@ -95,3 +95,4 @@ return;

}
executionContextMap.delete(asyncId);
suspend(() => executionContextMap.delete(asyncId));
};

@@ -98,0 +99,0 @@

@@ -103,2 +103,38 @@ const asyncHooks = require('async_hooks');

});
describe('Run', () => {
let spies;
let execute;
const initialContext = { initial: 'value' };
beforeEach(() => {
execute = jest.fn();
spies = {
contextCreate: jest.spyOn(Context, 'create'),
execute
};
Context.run(execute, initialContext);
});
it('Creates context', () => {
expect(spies.contextCreate).toHaveBeenCalledWith(initialContext);
});
it('Executes given function', () => {
expect(spies.execute).toHaveBeenCalledTimes(1);
});
it('Expose context to function execution', () => {
let exposedContext = undefined;
execute = jest.fn(() => {
exposedContext = Context.get();
});
Context.run(execute, initialContext);
expect(exposedContext).toEqual(expect.objectContaining(
initialContext
));
})
});
});

@@ -105,0 +141,0 @@