-
-
Save xavdid/c2e87a363bbd92a2c11eea147d558323 to your computer and use it in GitHub Desktop.
gzip test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* globals describe it */ | |
const should = require('should') | |
const zapier = require('zapier-platform-core') | |
// Use this to make test calls into your app: | |
const App = require('../../index') | |
const appTester = zapier.createAppTester(App) | |
zapier.tools.env.inject() | |
describe.only('My App', () => { | |
it('should run triggers.books', done => { | |
const bundle = { inputData: { query: 'artemis weir' } } | |
appTester(App.triggers.books.operation.perform, bundle) | |
.then(results => { | |
results.length.should.be.above(5) | |
done() | |
}) | |
.catch(done) | |
}) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// We can roll up all our behaviors in an App. | |
const App = { | |
// This is just shorthand to reference the installed dependencies you have. Zapier will | |
// need to know these before we can upload | |
version: require('./package.json').version, | |
platformVersion: require('zapier-platform-core').version, | |
// beforeRequest & afterResponse are optional hooks into the provided HTTP client | |
beforeRequest: [], | |
afterResponse: [], | |
// If you want to define optional resources to simplify creation of triggers, searches, creates - do that here! | |
resources: {}, | |
// If you want your trigger to show up, you better include it here! | |
triggers: { | |
books: { | |
key: 'books', | |
noun: 'Books', | |
display: { | |
label: 'Get Books', | |
description: 'Triggers on a new books.' | |
}, | |
operation: { | |
inputFields: [{ key: 'query', required: true }], | |
perform: (z, bundle) => { | |
return z | |
.request({ | |
url: 'https://www.googleapis.com/books/v1/volumes', | |
params: { | |
q: bundle.inputData.query | |
}, | |
headers: { | |
'user-agent': 'send me gzip' // for google, user agent must have "gzip" to be sent it | |
} | |
}) | |
.then(response => z.JSON.parse(response.content).items) | |
} | |
} | |
} | |
}, | |
// If you want your searches to show up, you better include it here! | |
searches: {}, | |
// If you want your creates to show up, you better include it here! | |
creates: {}, | |
authentication: {} | |
} | |
// Finally, export the app. | |
module.exports = App |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "zapier-platform-example-app-minimal", | |
"version": "1.0.0", | |
"description": "An example app for the Zapier platform.", | |
"repository": "zapier/zapier-platform-example-app-minimal", | |
"homepage": "https://zapier.com/", | |
"author": "Bryan Helmig <bryan@zapier.com>", | |
"license": "BSD-3-Clause", | |
"main": "index.js", | |
"scripts": { | |
"test": "node node_modules/mocha/bin/mocha --recursive" | |
}, | |
"engines": { | |
"node": "6.10.2", | |
"npm": ">=3.10.10" | |
}, | |
"dependencies": { | |
"zapier-platform-core": "zapier/zapier-platform-core#unzip_response_before_logging" | |
}, | |
"devDependencies": { | |
"mocha": "3.2.0", | |
"should": "11.2.1" | |
}, | |
"prettier": { | |
"semi": false, | |
"singleQuote": true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment