Created
June 29, 2021 21:42
-
-
Save j1n3l0/f8902e68491b43b4af85f1b45723a822 to your computer and use it in GitHub Desktop.
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
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