@globocom/backstage-functions-sandbox
Advanced tools
Comparing version 0.5.0 to 0.5.1
@@ -190,6 +190,6 @@ const vm = require('vm'); | ||
runLocalCode(filename, req) { | ||
runLocalCode(filename, req, { console } = {}) { | ||
return new Promise((accept, reject) => { | ||
const code = fs.readFileSync(filename, 'utf8'); | ||
const options = { prefix: filename }; | ||
const options = { prefix: filename, console }; | ||
const invalid = this.testSyntaxError(filename, code, options); | ||
@@ -196,0 +196,0 @@ |
{ | ||
"name": "@globocom/backstage-functions-sandbox", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "Sandbox for Backstage functions", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -385,3 +385,36 @@ const expect = require('chai').expect; | ||
}); | ||
describe('options', () => { | ||
it('should allow pass a console instance', (done) => { | ||
const filename = './test/support/valid.js'; | ||
const req = {}; | ||
const mockedConsole = { | ||
error: () => {}, | ||
log: () => {}, | ||
info: () => {}, | ||
warn: () => {}, | ||
}; | ||
const testSyntaxErrorCalls = []; | ||
testSandbox.testSyntaxError = (...args) => { | ||
testSyntaxErrorCalls.push(args); | ||
}; | ||
const runScriptCalls = []; | ||
testSandbox.runScript = (...args) => { | ||
runScriptCalls.push(args); | ||
return Promise.resolve(); | ||
}; | ||
testSandbox | ||
.runLocalCode(filename, req, { console: mockedConsole }) | ||
.then(() => { | ||
expect(testSyntaxErrorCalls[0][2].console).to.eql(mockedConsole); | ||
expect(runScriptCalls[0][2].console).to.eql(mockedConsole); | ||
done(); | ||
}).catch(err => done(err)); | ||
}); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46226
1161
28