Skip to content

Instantly share code, notes, and snippets.

@gnschenker
Created December 30, 2019 16:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gnschenker/e46e1cc6c5ad0e96470de8d2704e7296 to your computer and use it in GitHub Desktop.
Save gnschenker/e46e1cc6c5ad0e96470de8d2704e7296 to your computer and use it in GitHub Desktop.
Using the getToken util function to retrieve the bearer token
describe("Suite to test the glossary API", () => {
const uuidv1 = require('uuid/v1');
const https = require('https');
const httpsAgent = new https.Agent({ rejectUnauthorized: false });
const axios = require('axios');
const host = process.env.API_HOST || "localhost";
const baseUrl = `http://${host}:5000/api`;
console.log(`BaseURL: ${baseUrl}`);
const client = axios.create({
baseURL: baseUrl,
httpsAgent
})
const utils = require('./utils.js');
var token = "";
var headers = "";
beforeAll(async () => {
token = await utils.getToken();
headers = {
"Authorization": "Bearer " + token,
"Content-Type": "application/json"
}
});
describe("when calling /glossary", () => {
it("should return list of glossaries", async () => {
const response = await client.get('glossary');
expect(response.status).toBe(200);
expect(response.data.length).toBeGreaterThan(0);
expect(response.data[0].term).toBe('AccessToken');
})
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment