Skip to content

Instantly share code, notes, and snippets.

@j1n3l0
Created June 29, 2021 21:42
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 j1n3l0/f8902e68491b43b4af85f1b45723a822 to your computer and use it in GitHub Desktop.
Save j1n3l0/f8902e68491b43b4af85f1b45723a822 to your computer and use it in GitHub Desktop.
const chai = require('chai');
const chaiHttp = require('chai-http');
const nock = require('nock');
const axios = require('axios');
chai.use(chaiHttp);
const { expect, request } = chai;
class Client {
async uploadDocs(doc) {
const response = await axios.get('http://localhost/');
return Promise.resolve(response.data);
}
}
describe('Client', () => {
beforeEach(() => nock.cleanAll());
it('should #uploadDocs', async () => {
const scope = nock(/localhost/).get('/').reply(200, {success: true});
const client = new Client();
const response = await client.uploadDocs('new.doc');
expect(response).to.be.an('object');
expect(response).to.have.property('success', true);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment