-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathquery_entities_errors_test.js
70 lines (55 loc) · 2.56 KB
/
query_entities_errors_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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
const testedResource = require('../common.js').testedResource;
const http = require('../http.js');
const entitiesResource = testedResource + '/entities/';
const serializeParams = require('../common.js').serializeParams;
describe('Query Entity. Errors', () => {
it('Should raise error when Accept header does not imply application/json or application/ld+json. 005', async function() {
const headers = {
Accept: 'text/plain'
};
const response = await http.get(entitiesResource + '?type=dummy', headers);
expect(response.response).toHaveProperty('statusCode', 406);
});
it('Should raise error when no entity type nor entity attributes provided. 017', async function() {
const response = await http.get(entitiesResource);
expect(response.response).toHaveProperty('statusCode', 400);
});
it('Should raise error when filter query is syntactically incorrect 018', async function() {
const queryParams = {
type: 'T_Query',
q: 'a>>>4;c<<<5'
};
const response = await http.get(entitiesResource + '?' + serializeParams(queryParams));
expect(response.response).toHaveProperty('statusCode', 400);
});
it('Should raise error when geo query is syntactically incorrect. Bad georel 019', async function() {
const queryParams = {
type: 'T_Query',
georel: 'invalid',
geometry: 'Point',
coordinates: '[-5,10]'
};
const response = await http.get(entitiesResource + '?' + serializeParams(queryParams));
expect(response.response).toHaveProperty('statusCode', 400);
});
it('Should raise error when geo query is syntactically incorrect. Bad geometry 020', async function() {
const queryParams = {
type: 'T_Query',
georel: 'near;maxDistance==1000',
geometry: 'xxxxx',
coordinates: '[-5,10]'
};
const response = await http.get(entitiesResource + '?' + serializeParams(queryParams));
expect(response.response).toHaveProperty('statusCode', 400);
});
it('Should raise error when geo query is syntactically incorrect. Bad coordinates 021', async function() {
const queryParams = {
type: 'T_Query',
georel: 'near;maxDistance==1000',
geometry: 'Point',
coordinates: '[-5]'
};
const response = await http.get(entitiesResource + '?' + serializeParams(queryParams));
expect(response.response).toHaveProperty('statusCode', 400);
});
});