describe('functions_bearer_token', () => { it('should run', async () => { const {sample, mocks} = getSample(); await sample.callingFunction(null, mocks.res); assert(mocks.axios.get.calledTwice); assert.deepEqual(mocks.axios.get.firstCall.args[1], { headers: {'Metadata-Flavor': 'Google'}, }); assert(mocks.res.send.calledWith('function-response')); }); });
it('should keep "env" property from config', () => { process.env.NODE_ENV = 'mergetest2' const config = lib.Configuration.buildConfig(testConfig, 'mergetest2') assert(config.env) })
function returnThenable(thenable, expected) { const promise = Promise.resolve(true) return promise.thenReturn(thenable).then(function(v){ assert(v === expected); }); }
it('can get tuple with fixed-size array', async function() { const c = new FlexContract(ABI, {provider: provider, bytecode: BYTECODE}); await c.new(123).send(); const r = await c.returnMultipleWithFixedArray(2).call(); assert.equal(r.sum, 2 + 4 + 6); assert(_.isArray(r.items)); assert(r.items.length == 3); assert.deepEqual(r.items, [2, 4, 6]); });
describe("github 1063", function() { specify("should not cause error when called with no arguments", function() { return Promise.promisify(function(cb) { cb(); }, { multiArgs: true})().then(function(values) { assert(Array.isArray(values)); assert.strictEqual(values.length, 0); }); }) });
describe('Fabrix App', () => { it('should exist', () => { assert(global.app) }) })
it("works with two succeeding resources and one failing resource", async () => { const [d, e, f] = [disposer(), rejectedDisposer(3), disposer()]; assert(!d._obj.closed); assert(!f._obj.closed); await Promise.using(d, e, f, assert.fail).catch(e => { assert.equal(e, 3); }); assert(d._obj.closed); assert(f._obj.closed); });
it("works with a single promise", async () => { let ran = false; await Promise.using(Promise.resolve(3), (three) => { ran = true; assert.equal(three, 3); }); assert(ran); });
it('should set the value of a new, nested leaf node with no pre-existing path', () => { const config = new lib.Configuration(_.cloneDeep(testConfig), {NODE_ENV: 'test'}) assert(!config.get('foo')) config.set('foo.bar.new.path', 'test') assert.equal(config.get('foo.bar.new.path'), 'test') })
function returnThenableReject(thenable, expected) { const promise = Promise.resolve(true) return promise.thenReturn(thenable).then(assert.fail, function(v){ assert(v === expected); }); }