Skip to content

Commit 5f95a54

Browse files
committed
Run specs.
1 parent e930bf7 commit 5f95a54

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/spec.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,42 @@ describe('Context', () => {
100100
});
101101
});
102102
});
103+
104+
describe('Run', () => {
105+
let spies;
106+
let execute;
107+
const initialContext = { initial: 'value' };
108+
109+
beforeEach(() => {
110+
execute = jest.fn();
111+
spies = {
112+
contextCreate: jest.spyOn(Context, 'create'),
113+
execute
114+
};
115+
116+
Context.run(execute, initialContext);
117+
});
118+
119+
it('Creates context', () => {
120+
expect(spies.contextCreate).toHaveBeenCalledWith(initialContext);
121+
});
122+
123+
it('Executes given function', () => {
124+
expect(spies.execute).toHaveBeenCalledTimes(1);
125+
});
126+
127+
it('Expose context to function execution', () => {
128+
let exposedContext = undefined;
129+
execute = jest.fn(() => {
130+
exposedContext = Context.get();
131+
});
132+
133+
Context.run(execute, initialContext);
134+
expect(exposedContext).toEqual(expect.objectContaining(
135+
initialContext
136+
));
137+
})
138+
});
103139
});
104140

105141
describe('Context Availability', () => {

0 commit comments

Comments
 (0)