1
1
import { expect } from 'chai' ;
2
2
import { Context , Request } from '../../src/common' ;
3
- import { VmRunner } from '../../src/lib/vm' ;
4
- import { wrapCode , wrapCodeBrowser } from '../../src/plugins/built-in' ;
3
+ import { VmRunner as VmRunnerBrowser } from '../../src/lib/vm' ;
4
+ import { VmRunner as VmRunnerNode } from '../../src/lib/vm2' ;
5
+ import { wrapCode as wrapCodeNode , wrapCodeBrowser } from '../../src/plugins/built-in' ;
5
6
import * as utils from '../../src/lib/utils' ;
6
7
import { Logger } from '../../src/lib/logger' ;
7
8
@@ -14,7 +15,7 @@ describe('VmRunner', () => {
14
15
const req = new Request ( ) ;
15
16
const ctx = new Context ( ) ;
16
17
const logger = new Logger ( 'TESTER' ) ;
17
- const vPreProcess = await VmRunner . run ( vCode , { req, ctx, utils, logger } ) ;
18
+ const vPreProcess = await VmRunnerBrowser . run ( vCode , { req, ctx, utils, logger } ) ;
18
19
const vPostProcessingCallback = await vPreProcess ( ) ;
19
20
expect ( vPreProcess ) . not . eq ( undefined ) ;
20
21
expect ( req . message ) . not . eq ( 123 ) ;
@@ -26,12 +27,12 @@ describe('VmRunner', () => {
26
27
27
28
describe ( 'VM for Node' , ( ) => {
28
29
it ( 'should run the code' , async ( ) => {
29
- const vCode = wrapCodeBrowser ( `logger.info('Ok'); return () => {req.message = 123}` ) ;
30
+ const vCode = wrapCodeNode ( `logger.info('Ok'); return () => {req.message = 123}` ) ;
30
31
31
32
const req = new Request ( ) ;
32
33
const ctx = new Context ( ) ;
33
34
const logger = new Logger ( 'TESTER' ) ;
34
- const vPreProcess = await VmRunner . run ( vCode , { req, ctx, utils, logger } ) ;
35
+ const vPreProcess = await VmRunnerNode . run ( vCode , { req, ctx, utils, logger } ) ;
35
36
const vPostProcessingCallback = await vPreProcess ( ) ;
36
37
expect ( vPreProcess ) . not . eq ( undefined ) ;
37
38
expect ( req . message ) . not . eq ( 123 ) ;
0 commit comments