Skip to content

Commit

Permalink
ParseServer is a class
Browse files Browse the repository at this point in the history
  • Loading branch information
flovilmart committed Mar 11, 2016
1 parent 2c991a4 commit 82ed4d8
Show file tree
Hide file tree
Showing 2 changed files with 239 additions and 162 deletions.
62 changes: 62 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,64 @@ 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");
console.log("query")
return q.first();
}).then((obj) => {
console.log("result");
expect(obj.id).toEqual(objId);
server.close();
done();
}).fail((err) => {
server.close();
done();
})
});
});
Loading

0 comments on commit 82ed4d8

Please sign in to comment.