-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathrows-graphQl.js
More file actions
64 lines (59 loc) · 2.21 KB
/
Copy pathrows-graphQl.js
File metadata and controls
64 lines (59 loc) · 2.21 KB
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
/*
* Copyright (c) 2015-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
*/
const testconfig = require('../etc/test-config.js');
const marklogic = require('../');
const db = marklogic.createDatabaseClient(testconfig.restWriterConnection);
const assert = require('assert');
const testlib = require("../etc/test-lib");
const volumeSet = new Set().add('118').add('120');
const dateSet = new Set().add('1970-12-07').add('1968-12-07');
const idSet = new Set().add(123).add(456);
const issnSet = new Set().add('1234').add('5678');
let serverConfiguration = {};
describe('graphQL endpoint tests', function() {
this.timeout(6000);
before(function (done) {
try {
testlib.findServerConfiguration(serverConfiguration);
setTimeout(()=>{
if(serverConfiguration.serverVersion < 11){
this.skip();
}
done();}, 3000);
} catch(error){
done(error);
}
});
it('should throw error when graphql query is not provided', function (done) {
try{
db.rows.graphQL();
} catch (e){
assert(e.toString().includes('graphql query required'));
done();
}
});
it('should return values based on the graphQL query.', function (done) {
const q = {"query": "query AllPublications { Medical_Publications { ID ISSN Volume Date } }"};
db.rows.graphQL(q).then(res => {
const publications = res.data.Medical_Publications;
assert(publications);
assert(publications.length === 2);
assert(volumeSet.has(publications[0].Volume));
assert(volumeSet.has(publications[1].Volume));
assert(dateSet.has(publications[0].Date));
assert(dateSet.has(publications[1].Date));
assert(idSet.has(publications[0].ID));
assert(idSet.has(publications[1].ID));
assert(issnSet.has(publications[0].ISSN));
assert(issnSet.has(publications[1].ISSN));
done();
}).catch(e => {
done(e);
});
});
after(function(done){
marklogic.releaseClient(db);
done();
});
});