Fix inferTitle test broken on Node 8

This commit is contained in:
Ronan Jouchet 2020-03-15 17:19:19 -04:00
parent 20de73c559
commit d6e7aa6f41
1 changed files with 8 additions and 3 deletions

View File

@ -1,17 +1,22 @@
import axios from 'axios';
import axios, { AxiosResponse } from 'axios';
import { inferTitle } from './inferTitle';
test('it returns the correct title', async () => {
const axiosGetMock = jest.spyOn(axios, 'get');
axiosGetMock.mockResolvedValue({
const mockedResponse: AxiosResponse<string> = {
data: `
<HTML>
<head>
<title>TEST_TITLE</title>
</head>
</HTML>`,
});
status: 200,
statusText: 'OK',
headers: {},
config: {},
};
axiosGetMock.mockResolvedValue(mockedResponse);
const result = await inferTitle('someurl');
expect(axiosGetMock).toHaveBeenCalledTimes(1);