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')); }); });
specify("Should not promisify Object.prototype methods", function() { var o = {method: function(){}}; Promise.promisifyAll(o); assert.deepEqual(["method", "methodAsync"].sort(), Object.keys(o).sort()); });
it("should allow returning promises", function() { var a = [promised(1), promised(2), promised(3)]; return Promise.reduce(a, function(total, a) { return promised(5).then(function(b) { return total + a + b; }); }, 0).then(function(total){ assert.equal(total, 1+5 + 2+5 + 3+5); }); });
it('should return only visible fragments in getVisibleText()', function () { var parser = new Parser(); var fixture = util.getFixture("email_2_1.txt"); var email = parser.parse(fixture); var fragments = email.getFragments(); var visibleFragments = _.filter(fragments, f => !f.isHidden()); var visibleText = _.map(visibleFragments, f => f.getContent()).join('\n'); assert.equal(email.getVisibleText(), visibleText, "Visible text doesn't match"); });
describe('ConfigNotDefinedError', () => { it('#name', () => { const err = new Errors.ConfigNotDefinedError() assert.equal(err.name, 'ConfigNotDefinedError') }) })
it("spreads promises for arrays across arguments", function () { return Promise.resolve([Promise.resolve(10)]) .all() .spread(function (value) { assert.equal(value,10); }); });
it('should not hang on to email instances', function () { var parser = new Parser(); var fixture = util.getFixture("email_1.txt"); var email1 = parser.parse(fixture); var email2 = parser.parse(fixture); assert.notStrictEqual(email1, email2, 'Email instances should not be the same'); assert.deepEqual(email1, email2, 'Email instances should have been the same'); // should be same content });
it('should handle Italian emails', function () { var parser = new Parser(); var fixture = util.getFixture("email_7.txt"); var email = parser.parse(fixture); var fragments = email.getFragments(); assert.equal(fragments[0].getContent().trim(), COMMON_FIRST_FRAGMENT, "Doesn't match common fragment"); });
describe('IllegalAccessError', () => { it('#name', () => { const err = new Errors.IllegalAccessError() assert.equal(err.name, 'IllegalAccessError') }) })
it('should handle square brackets in emails', function () { var parser = new Parser(); var fixture = util.getFixture("email_12.txt"); var email = parser.parse(fixture); var fragments = email.getFragments(); assert.equal(fragments[0].getContent().trim(), COMMON_FIRST_FRAGMENT, "Doesn't match common fragment"); });