Add test for inferTitle
This commit is contained in:
parent
04e2f64ba7
commit
49272d1a89
|
@ -0,0 +1,21 @@
|
|||
import axios from 'axios';
|
||||
import inferTitle from './inferTitle';
|
||||
|
||||
jest.mock('axios', () =>
|
||||
jest.fn(() =>
|
||||
Promise.resolve({
|
||||
data: `
|
||||
<HTML>
|
||||
<head>
|
||||
<title>TEST_TITLE</title>
|
||||
</head>
|
||||
</HTML>`,
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
test('it returns the correct title', async () => {
|
||||
const result = await inferTitle('someurl');
|
||||
expect(axios).toHaveBeenCalledTimes(1);
|
||||
expect(result).toBe('TEST_TITLE');
|
||||
});
|
Loading…
Reference in New Issue