File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff 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' , ( ) => {
You can’t perform that action at this time.
0 commit comments