Added basic test coverage for the search index module

refs https://github.com/TryGhost/Team/issues/1665

- As with all the code we should be aiming for 100% test coverage :) This is a groundwork for testing code that uses HTTP requests
- nock was used as it's a library we use in the rest of the projects already
This commit is contained in:
Naz 2022-07-05 10:52:42 +02:00
parent f6838e2113
commit ce4206e91f

View File

@ -0,0 +1,19 @@
import {init} from './search-index';
import nock from 'nock';
describe('search index', function () {
test('initializes search index', async () => {
const apiUrl = 'http://localhost/ghost/api/content';
const apiKey = 'secret_key';
const scope = nock('http://localhost/ghost/api/content')
.get('/posts/?key=secret_key&limit=all&fields=id,title,excerpt,url,updated_at,visibility&order=updated_at%20desc&formats=plaintext')
.reply(200, {
posts: [{}]
});
await init({apiUrl, apiKey});
expect(scope.isDone()).toBeTruthy();
});
});