Skip to content

Commit 6fe050b

Browse files
committed
Add read/write test for _GlobalConfig
1 parent c8792b4 commit 6fe050b

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

spec/ParseGlobalConfig.spec.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// run test when changing related file using
2+
// $ TESTING=1 node_modules/jasmine/bin/jasmine.js spec/ParseGlobalConfig.spec.js
3+
4+
var auth = require('../Auth');
5+
var cache = require('../cache');
6+
var Config = require('../Config');
7+
var DatabaseAdapter = require('../DatabaseAdapter');
8+
var Parse = require('parse/node').Parse;
9+
var rest = require('../rest');
10+
11+
var config = new Config('test');
12+
var database = DatabaseAdapter.getDatabaseConnection('test');
13+
14+
describe('GlobalConfig', () => {
15+
beforeEach(function() {
16+
database.create('_GlobalConfig', { objectId: 1, params: { mostValuableCompany: 'Apple' } }, {});
17+
});
18+
19+
it('find existing values', (done) => {
20+
rest.find(config, auth.nobody(config), '_GlobalConfig', 1)
21+
.then(() => {
22+
return database.mongoFind('_GlobalConfig', {}, {});
23+
}).then((results) => {
24+
expect(results.length).toEqual(1);
25+
var obj = results[0];
26+
expect(obj.params.mostValuableCompany).toEqual('Apple');
27+
done();
28+
}).catch((error) => { console.log(error); });
29+
});
30+
31+
it('update with a new value', (done) => {
32+
var input = {
33+
params: {
34+
mostValuableCompany: 'Alphabet'
35+
}
36+
};
37+
rest.update(config, auth.nobody(config), '_GlobalConfig', 1, input)
38+
.then(() => {
39+
return database.mongoFind('_GlobalConfig', {}, {});
40+
}).then((results) => {
41+
expect(results.length).toEqual(1);
42+
var obj = results[0];
43+
expect(obj.params.mostValuableCompany).toEqual('Alphabet');
44+
done();
45+
}).catch((error) => { console.log(error); });
46+
});
47+
48+
49+
});

0 commit comments

Comments
 (0)