|
1 | 1 |
|
2 | 2 | var request = require('request'); |
| 3 | +var Parse = require('parse/node').Parse; |
3 | 4 | var DatabaseAdapter = require('../src/DatabaseAdapter'); |
4 | 5 |
|
5 | 6 | var database = DatabaseAdapter.getDatabaseConnection('test'); |
@@ -58,4 +59,43 @@ describe('a GlobalConfig', () => { |
58 | 59 | }); |
59 | 60 | }); |
60 | 61 |
|
| 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 | + |
61 | 101 | }); |
0 commit comments