File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717 "clear" : " rm -rf ./dist && rm -rf ./tsconfig.build.tsbuildinfo"
1818 },
1919 "dependencies" : {
20- "@editorjs/model" : " workspace:^"
20+ "@editorjs/model" : " workspace:^" ,
21+ "@editorjs/sdk" : " workspace:^"
2122 },
2223 "devDependencies" : {
2324 "@jest/globals" : " ^29.7.0" ,
Original file line number Diff line number Diff line change 1+ import { getContext , runWithContext , WithContext } from './Context.js' ;
2+
3+ describe ( 'Context util' , ( ) => {
4+ it ( 'should run function in context' , ( ) => {
5+ const func = ( ) : string | undefined => {
6+ return getContext < string > ( ) ;
7+ } ;
8+
9+ expect ( runWithContext ( 'context' , func ) ) . toEqual ( 'context' ) ;
10+ } ) ;
11+
12+ it ( 'should run several functions in context respectively' , ( ) => {
13+ const func = ( ) : string | undefined => {
14+ return getContext < string > ( ) ;
15+ } ;
16+
17+ const result1 = runWithContext ( 'context1' , func ) ;
18+ const result2 = runWithContext ( 'context2' , func ) ;
19+
20+ expect ( result1 ) . toEqual ( 'context1' ) ;
21+ expect ( result2 ) . toEqual ( 'context2' ) ;
22+ } ) ;
23+
24+ it ( 'should run method in context' , ( ) => {
25+ // eslint-disable-next-line jsdoc/require-jsdoc
26+ class Test {
27+ @WithContext
28+ // eslint-disable-next-line @typescript-eslint/no-unused-vars,no-unused-vars,jsdoc/require-jsdoc
29+ public method ( _context : string ) : string | undefined {
30+ return getContext < string > ( ) ;
31+ }
32+ }
33+
34+ const instance = new Test ( ) ;
35+
36+ expect ( instance . method ( 'context' ) ) . toEqual ( 'context' ) ;
37+ } ) ;
38+ } ) ;
Original file line number Diff line number Diff line change @@ -645,6 +645,7 @@ __metadata:
645645 resolution : " @editorjs/collaboration-manager@workspace:packages/collaboration-manager"
646646 dependencies :
647647 " @editorjs/model " : " workspace:^"
648+ " @editorjs/sdk " : " workspace:^"
648649 " @jest/globals " : " npm:^29.7.0"
649650 " @stryker-mutator/core " : " npm:^7.0.2"
650651 " @stryker-mutator/jest-runner " : " npm:^7.0.2"
You can’t perform that action at this time.
0 commit comments