Skip to content

Instantly share code, notes, and snippets.

@ploeber
Created May 16, 2023 16:40
Show Gist options
  • Save ploeber/1dd535a7f7404712e8ff95cd88f4422b to your computer and use it in GitHub Desktop.
Save ploeber/1dd535a7f7404712e8ff95cd88f4422b to your computer and use it in GitHub Desktop.
/* globals describe, it, expect */
const zapier = require('zapier-platform-core');
const App = require('../index');
const appTester = zapier.createAppTester(App);
// Load .env file variables
zapier.tools.env.inject()
describe('custom auth', () => {
it('passes authentication and returns json', async () => {
const bundle = {
authData: {
apiKey: process.env.ASSEMBLYAI_KEY,
},
};
const response = await appTester(App.authentication.test, bundle);
expect(response.status === 200);
});
it('fails on bad auth', async () => {
const bundle = {
authData: {
apiKey: 'bad',
},
};
try {
await appTester(App.authentication.test, bundle);
} catch (error) {
expect(error.message).toContain('The API Key you supplied is incorrect');
return;
}
throw new Error('appTester should have thrown');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment