mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2024-09-29 04:39:04 +00:00
Fix inferTitle test broken on Node 8
This commit is contained in:
parent
20de73c559
commit
d6e7aa6f41
@ -1,17 +1,22 @@
|
|||||||
import axios from 'axios';
|
import axios, { AxiosResponse } from 'axios';
|
||||||
|
|
||||||
import { inferTitle } from './inferTitle';
|
import { inferTitle } from './inferTitle';
|
||||||
|
|
||||||
test('it returns the correct title', async () => {
|
test('it returns the correct title', async () => {
|
||||||
const axiosGetMock = jest.spyOn(axios, 'get');
|
const axiosGetMock = jest.spyOn(axios, 'get');
|
||||||
axiosGetMock.mockResolvedValue({
|
const mockedResponse: AxiosResponse<string> = {
|
||||||
data: `
|
data: `
|
||||||
<HTML>
|
<HTML>
|
||||||
<head>
|
<head>
|
||||||
<title>TEST_TITLE</title>
|
<title>TEST_TITLE</title>
|
||||||
</head>
|
</head>
|
||||||
</HTML>`,
|
</HTML>`,
|
||||||
});
|
status: 200,
|
||||||
|
statusText: 'OK',
|
||||||
|
headers: {},
|
||||||
|
config: {},
|
||||||
|
};
|
||||||
|
axiosGetMock.mockResolvedValue(mockedResponse);
|
||||||
const result = await inferTitle('someurl');
|
const result = await inferTitle('someurl');
|
||||||
|
|
||||||
expect(axiosGetMock).toHaveBeenCalledTimes(1);
|
expect(axiosGetMock).toHaveBeenCalledTimes(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user