mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 05:50:35 +03:00
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:
parent
f6838e2113
commit
ce4206e91f
19
ghost/sodo-search/src/search-index.test.js
Normal file
19
ghost/sodo-search/src/search-index.test.js
Normal 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();
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user