Skip to content

Commit f039b70

Browse files
committed
Add test for uncovered cases
1 parent 84b35ea commit f039b70

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

spec/ParseGlobalConfig.spec.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
var request = require('request');
3+
var Parse = require('parse/node').Parse;
34
var DatabaseAdapter = require('../src/DatabaseAdapter');
45

56
var database = DatabaseAdapter.getDatabaseConnection('test');
@@ -58,4 +59,43 @@ describe('a GlobalConfig', () => {
5859
});
5960
});
6061

62+
it('failed getting config when it is missing', (done) => {
63+
database.rawCollection('_GlobalConfig')
64+
.then(coll => coll.deleteOne({ '_id': 1}, {}, {}))
65+
.then(_ => {
66+
request.get({
67+
url: 'http://localhost:8378/1/config',
68+
json: true,
69+
headers: {
70+
'X-Parse-Application-Id': 'test',
71+
'X-Parse-Master-Key': 'test',
72+
},
73+
}, (error, response, body) => {
74+
expect(response.statusCode).toEqual(404);
75+
expect(body.code).toEqual(Parse.Error.INVALID_KEY_NAME);
76+
done();
77+
});
78+
});
79+
});
80+
81+
it('failed updating config when it is missing', (done) => {
82+
database.rawCollection('_GlobalConfig')
83+
.then(coll => coll.deleteOne({ '_id': 1}, {}, {}))
84+
.then(_ => {
85+
request.post({
86+
url: 'http://localhost:8378/1/config',
87+
json: true,
88+
body: { params: { companies: ['US', 'DK', 'SE'] } },
89+
headers: {
90+
'X-Parse-Application-Id': 'test',
91+
'X-Parse-Master-Key': 'test'
92+
},
93+
}, (error, response, body) => {
94+
expect(response.statusCode).toEqual(404);
95+
expect(body.code).toEqual(Parse.Error.INVALID_KEY_NAME);
96+
done();
97+
});
98+
});
99+
});
100+
61101
});

0 commit comments

Comments
 (0)