Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
beforeEach(() => {
Handlers = TestDouble.replace('../lib/handlers', {
network: TestDouble.func('network')
});
// fetch = TestDouble.func('fetch');
request.plugins.cloudapi.fetch = () => {};
Formatters = require('../lib/formatters');
});
it("it works as a command's beforeRun()", function() {
let command, availableOptions;
td.replace(Blueprint, 'lookup', td.function());
td.when(Blueprint.lookup('test-blueprint'), { ignoreExtraArgs: true }).thenReturn({
availableOptions: [{ name: 'custom-blueprint-option', type: String }],
});
command = buildCommand();
command.beforeRun(['test-blueprint']);
availableOptions = map(command.availableOptions, 'name');
expect(availableOptions).to.contain('verbose');
expect(availableOptions).to.contain('custom-blueprint-option');
});
});
it('should use the boundary to fit the bounds on the screen', () => {
let options = {};
let tableBoundaryResponse = 'empire';
td.replace(kb._spec.helper, 'getTableBoundary');
td.replace(map, 'fitBounds');
td.when(kb._spec.helper.getTableBoundary(any()))
.thenResolve(tableBoundaryResponse);
td.when(map.fitBounds(tableBoundaryResponse, any()))
.thenReturn('success');
kb.zoomToBounds(map, options).should.eventually.deep.equal('success');
});
});
class PeerPool extends EventEmitter { }
PeerPool.prototype.open = td.func()
td.replace('../../lib/net/peerpool', PeerPool)
td.replace('../../lib/net/protocol/flowcontrol')
const Chain = td.constructor()
Chain.prototype.open = td.func()
td.replace('../../lib/blockchain', { Chain })
const EthProtocol = td.constructor()
const LesProtocol = td.constructor()
td.replace('../../lib/net/protocol/ethprotocol', EthProtocol)
td.replace('../../lib/net/protocol/lesprotocol', LesProtocol)
class FastSynchronizer extends EventEmitter { }
FastSynchronizer.prototype.start = td.func()
FastSynchronizer.prototype.stop = td.func()
FastSynchronizer.prototype.open = td.func()
td.replace('../../lib/sync/fastsync', FastSynchronizer)
const FastEthereumService = require('../../lib/service/fastethereumservice')
t.test('should initialize correctly', async (t) => {
let service = new FastEthereumService()
t.ok(service.synchronizer instanceof FastSynchronizer, 'fast mode')
t.equals(service.name, 'eth', 'got name')
t.end()
})
t.test('should get protocols', async (t) => {
let service = new FastEthereumService()
t.ok(service.protocols[0] instanceof EthProtocol, 'fast protocols')
t.notOk(service.protocols[1], 'no light protocol')
service = new FastEthereumService({ lightserv: true })
t.ok(service.protocols[0] instanceof EthProtocol, 'fast protocols')
t.ok(service.protocols[1] instanceof LesProtocol, 'lightserv protocols')
beforeEach('create fakes', () => {
encodeClose = td.function();
td.replace('../../../lib/Protocol/Protobuf/Adapters/Session', { encodeClose });
FakeClient = require('../../../lib/Protocol/Client');
encodeMessage = td.replace(FakeClient.prototype, 'encodeMessage');
});
beforeEach(() => {
td.replace(nabs, 'makeArray');
});
beforeEach('create fakes', () => {
preparing = td.function();
td.replace('../../../lib/DevAPI/Preparing', preparing);
tableUpdate = require('../../../lib/DevAPI/TableUpdate');
});
beforeEach(async () => {
garden = await makeTestGarden(projectRoot, [gardenPlugin])
ctx = garden.pluginContext
env = garden.getEnvironment()
td.replace(garden.buildDir, "syncDependencyProducts", () => null)
})
test.before(()=> {
process.chdir('../fixtures/test-api')
apiGateway = td.replace('../../src/util/api-gateway')
lambda = td.replace('../../src/util/lambda')
deployFunction = td.replace('../../src/deploy-function/exec')
td.when(apiGateway.createDeployment(td.matchers.isA(Object))).thenReturn(Promise.resolve({}))
td.when(lambda.publishVersion(td.matchers.isA(Object))).thenReturn(Promise.resolve({}))
td.when(lambda.addPermission(td.matchers.isA(Object))).thenReturn(Promise.resolve({}))
td.when(lambda.updateAlias(td.matchers.isA(Object))).thenReturn(Promise.resolve({ AliasArn: 'arn:aws:lambda:us-east-1:654843952338:function:graph-api-graph-ql:'}))
td.when(lambda.getAlias(td.matchers.isA(Object))).thenReturn(Promise.resolve({}))
td.when(deployFunction(td.matchers.isA(Object)), { ignoreExtraArgs: true }).thenReturn(Promise.resolve({ FunctionName: 'test' }))
const deploy = require('../../src/deploy/exec')
return deploy({ region: 'us-east-1'})
})
beforeEach: function () {
td.replace(authenticator, 'login')
},
allRolesIfAuthenticated: function () {