Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import {unmountComponentAtNode} from 'react-dom';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import chaiDOM from 'chai-dom';
import sinonChai from 'sinon-chai';
import chaiEnzyme from 'chai-enzyme';
import sinon from 'sinon';
chai.use(chaiAsPromised);
chai.use(chaiDOM);
chai.use(sinonChai);
chai.use(chaiEnzyme());
Object.assign(window, {
sinon,
sandbox: sinon.createSandbox(),
chai,
should: chai.should()
});
afterEach(function restoreSandbox() {
window.sandbox.restore();
Array.from(document.body.children).forEach(child => {
if (child._reactRootContainer) {
unmountComponentAtNode(child);
}
});
});
describe('src/dev/build/tasks/nodejs/download_node_builds_task', () => {
const sandbox = sinon.createSandbox();
afterEach(() => {
sandbox.restore();
});
function setup({ failOnUrl } = {}) {
const platforms = [
{ getName: () => 'foo' },
{ getName: () => 'bar' },
];
const log = {};
const config = {
getNodePlatforms: () => platforms,
getNodeVersion: () => 'nodeVersion',
};
setup(() => {
sb = sinon.createSandbox();
sb.stub(vscode.window, 'showInformationMessage').resolves('Download and install');
});
beforeEach(function() {
sandbox = sinon.createSandbox();
processCtl = new ProcessCtl('test', config);
});
describe('ServiceObject', () => {
let serviceObject: ServiceObject;
const sandbox = sinon.createSandbox();
const CONFIG = {
baseUrl: 'base-url',
parent: {} as Service,
id: 'id',
createMethod: util.noop,
requestModule: {} as typeof r,
};
beforeEach(() => {
serviceObject = new ServiceObject(CONFIG);
});
afterEach(() => {
sandbox.restore();
});
describe("context", () => {
const sandbox = sinon.createSandbox();
let scratch: HTMLDivElement;
const render = (comp: JSX.Element) =>
preactRender(comp, scratch, scratch.lastChild as Element);
before(() => {
scratch = document.createElement("div");
document.body.appendChild(scratch);
});
beforeEach(() => {
options.debounceRendering = r => r();
render();
});
describe('ZAFClient', () => {
const sandbox = sinon.createSandbox()
afterEach(() => {
sandbox.restore()
})
describe('.init', () => {
describe('given origin and app_guid exist', () => {
describe('when a callback is passed', () => {
const callback = function () { return 'abcxyz' }
callback.bind = function () { return callback }
beforeEach(() => {
sandbox.spy(Client.prototype, 'on')
ZAFClient.init(callback, { hash: 'origin=https://subdomain.zendesk.com&app_guid=A2' })
})
beforeEach(() => {
sandbox = sinon.createSandbox()
signersManagerInstance = new SignersManager(
ApiCaller.getInstance('https://api.test.com')
)
})
beforeEach(() => {
generateIdStub = sinon.stub();
mockery.registerMock('../utils/functions', {
generateId: generateIdStub,
});
cleanCache();
VehicleContract = requireVehicleContract();
sandbox = sinon.createSandbox();
contract = new VehicleContract();
ctx = sinon.createStubInstance(VehicleManufactureNetContext);
stub = sinon.createStubInstance(ChaincodeStub);
clientIdentity = sinon.createStubInstance(VehicleManufactureNetClientIdentity);
participantList = sinon.createStubInstance(ParticipantList);
orderList = sinon.createStubInstance(AssetList);
vehicleList = sinon.createStubInstance(AssetList);
policyList = sinon.createStubInstance(AssetList);
usageList = sinon.createStubInstance(AssetList);
organization = sinon.createStubInstance(Organization);
participant = sinon.createStubInstance(Participant);
(clientIdentity as any)._participant = participant;
(clientIdentity as any)._organization = organization;
beforeEach(() => { sandbox = sinon.createSandbox() })
afterEach(() => { sandbox.restore() })