UNPKG

line-api-cli

Version:
33 lines (27 loc) 857 B
import Axios from 'axios'; import ThingsRequest from '../things-request'; describe('ThingsRequest', () => { describe('when create instance with options.accessToken', () => { let req; let accessToken = 'someaccesstoken'; beforeAll(() => { jest.spyOn(Axios, 'create'); req = new ThingsRequest({ accessToken }); }); it('should have correct endpoint', () => { expect(req.endpoint).toEqual('https://api.line.me/things/v1'); }); it('should create axios instance with correct headers for LINE API', () => { expect(Axios.create).toHaveBeenCalledWith({ headers: { authorization: `Bearer ${accessToken}`, 'content-type': 'application/json' } }); expect(req.axios).toBeDefined(); }); afterAll(() => { Axios.create.mockRestore(); }); }); });