-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsearch-documents-filters.test.js
42 lines (34 loc) · 1.29 KB
/
search-documents-filters.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const QueryString = require('querystring');
const testWithServer = require('./helpers/test-with-server');
const dir = __dirname.split('/')[__dirname.split('/').length - 1];
const file = dir + __filename.replace(__dirname, '') + ' > ';
testWithServer(file + 'Should accept params in filter[PARAM_NAME] format for documents type', {}, async (t, ctx) => {
t.plan(1);
const htmlRequest = {
method: 'GET',
url: '/search/documents?' + QueryString.stringify({
q: 'babbage',
'filter[archive]': 'The Babbage Papers',
'filter[organisations]': 'Science Museum, London'
}),
headers: { Accept: 'text/html' }
};
const res = await ctx.server.inject(htmlRequest);
t.equal(res.statusCode, 200, 'Status code was as expected');
t.end();
});
testWithServer(file + 'Search for docs with images', {}, async (t, ctx) => {
t.plan(1);
const htmlRequest = {
method: 'GET',
url: '/search/documents?' + QueryString.stringify({
q: 'calculating machine',
'filter[archive]': 'The Babbage Papers'
}),
headers: { Accept: 'text/html' }
};
const res = await ctx.server.inject(htmlRequest);
t.equal(res.statusCode, 200, 'Status code was as expected');
// t.ok(res.payload.indexOf('class="resultcard__figure"') > -1, 'image shows in results');
t.end();
});