mirror of
https://github.com/embarklabs/embark.git
synced 2025-02-03 09:24:25 +00:00
dcaa2626d9
Bumps [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) from 22.5.1 to 23.8.1. - [Release notes](https://github.com/jest-community/eslint-plugin-jest/releases) - [Changelog](https://github.com/jest-community/eslint-plugin-jest/blob/master/CHANGELOG.md) - [Commits](https://github.com/jest-community/eslint-plugin-jest/compare/v22.5.1...v23.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
import assert from 'assert';
|
|
import sinon from 'sinon';
|
|
import { fakeEmbark } from 'embark-testing';
|
|
import CodeRunner from '../src/';
|
|
|
|
/* eslint jest/expect-expect: ["error", { "assertFunctionNames": ["assert", "expect"] }] */
|
|
|
|
// Due to our `DAPP_PATH` dependency in `embark-utils` `dappPath()`, we need to
|
|
// ensure that this environment variable is defined.
|
|
process.env.DAPP_PATH = 'something';
|
|
|
|
describe('core/code-runner', () => {
|
|
|
|
const { embark } = fakeEmbark();
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
let codeRunner;
|
|
|
|
beforeEach(() => {
|
|
codeRunner = new CodeRunner(embark);
|
|
});
|
|
|
|
afterEach(() => {
|
|
embark.teardown();
|
|
sinon.restore();
|
|
});
|
|
|
|
test('it should register variables and eval code in the VM', async () => {
|
|
const testVar = {
|
|
foo: 'bar'
|
|
};
|
|
await embark.events.request2('runcode:register', 'testVar', testVar);
|
|
const context = await embark.events.request2('runcode:getContext');
|
|
assert.equal(context['testVar'], testVar);
|
|
});
|
|
|
|
test('it should run code in the VM', async () => {
|
|
const testVar = {
|
|
foo: 'bar'
|
|
};
|
|
await embark.events.request2('runcode:register', 'testVar', testVar);
|
|
// `runcode:eval` throws a `ReferenceError` if `testVar` wasn't registered
|
|
// in the VM.
|
|
await embark.events.request2('runcode:eval', `testVar.foo = 'bar';`);
|
|
assert(true);
|
|
});
|
|
});
|