UNPKG

datafire

Version:

[![Travis][travis-image]][travis-link] [![Downloads][downloads-image]][npm-link] [![NPM version][npm-image]][npm-link] [![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://www.npmjs.com/package/datafire) <!--[![Dependency status][deps-i

69 lines (59 loc) 1.7 kB
'use strict'; let datafire = require('../entry'); let expect = require('chai').expect; let integ = new datafire.Integration({ id: 'test_integration', security: { test_integration: { fields: { password: 'your password', } } } }); integ.addAction('password.get', { handler: (input, context) => { return context.accounts.test_integration.password; } }) integ.addAction('echoContext', { handler: (input, context) => context }) let integInstance = integ.create({password: 'foobar'}); describe('IntegrationInstance', () => { it('should use account set at top level', () => { return integInstance.password.get() .then(pw => expect(pw).to.equal('foobar')); }); it('should not use account passed to action', () => { let ctx = new datafire.Context({ accounts: { test_integration: {password: 'baz'} } }); return integInstance.password.get({}, ctx) .then(pw => expect(pw).to.equal('foobar')) }); it('should still have access to local context', () => { let ctx = new datafire.Context({ type: 'http', accounts: { test_integration: {password: 'baz'} } }); return integInstance.echoContext({}, ctx) .then(ctxOut => { expect(ctxOut.accounts.test_integration.password).to.equal('foobar'); expect(ctxOut.type).to.equal('http'); }) }); it('should not have access to extra accounts', () => { let ctx = new datafire.Context({ accounts: { other_integration: {password: 'baz'} } }); return integInstance.echoContext({}, ctx) .then(ctx => expect(ctx.accounts.other_integration).to.equal(undefined)) }) })