Skip to content

Commit

Permalink
Merge pull request #980 from ParsePlatform/flovilmart.ParseServerClass
Browse files Browse the repository at this point in the history
ParseServer is a class
  • Loading branch information
flovilmart committed Mar 21, 2016
2 parents fb57d91 + 260cc21 commit 4bd32c8
Show file tree
Hide file tree
Showing 2 changed files with 243 additions and 169 deletions.
60 changes: 60 additions & 0 deletions spec/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
var request = require('request');
var parseServerPackage = require('../package.json');
var MockEmailAdapterWithOptions = require('./MockEmailAdapterWithOptions');
var ParseServer = require("../src/index");
var express = require('express');

describe('server', () => {
it('requires a master key and app id', done => {
Expand Down Expand Up @@ -168,4 +170,62 @@ describe('server', () => {
done();
})
});

it('can create a parse-server', done => {
var parseServer = new ParseServer.default({
appId: "aTestApp",
masterKey: "aTestMasterKey",
serverURL: "http://localhost:12666/parse",
databaseURI: 'mongodb://localhost:27017/aTestApp'
});

expect(Parse.applicationId).toEqual("aTestApp");
var app = express();
app.use('/parse', parseServer.app);

var server = app.listen(12666);
var obj = new Parse.Object("AnObject");
var objId;
obj.save().then((obj) => {
objId = obj.id;
var q = new Parse.Query("AnObject");
return q.first();
}).then((obj) => {
expect(obj.id).toEqual(objId);
server.close();
done();
}).fail((err) => {
server.close();
done();
})
});

it('can create a parse-server', done => {
var parseServer = ParseServer.ParseServer({
appId: "anOtherTestApp",
masterKey: "anOtherTestMasterKey",
serverURL: "http://localhost:12667/parse",
databaseURI: 'mongodb://localhost:27017/anotherTstApp'
});

expect(Parse.applicationId).toEqual("anOtherTestApp");
var app = express();
app.use('/parse', parseServer);

var server = app.listen(12667);
var obj = new Parse.Object("AnObject");
var objId;
obj.save().then((obj) => {
objId = obj.id;
var q = new Parse.Query("AnObject");
return q.first();
}).then((obj) => {
expect(obj.id).toEqual(objId);
server.close();
done();
}).fail((err) => {
server.close();
done();
})
});
});
Loading

0 comments on commit 4bd32c8

Please sign in to comment.