Use Prettier JS (#5017)

* Adds prettier

* Run lint before tests
This commit is contained in:
Florent Vilmart
2018-09-01 13:58:06 -04:00
committed by GitHub
parent 189cd259ee
commit d83a0b6808
240 changed files with 41098 additions and 29020 deletions

View File

@@ -1,43 +1,46 @@
const Parse = require('parse/node').Parse;
const PostgresStorageAdapter = require('../lib/Adapters/Storage/Postgres/PostgresStorageAdapter').default;
const postgresURI = 'postgres://localhost:5432/parse_server_postgres_adapter_test_database';
const ParseServer = require("../lib/index");
const PostgresStorageAdapter = require('../lib/Adapters/Storage/Postgres/PostgresStorageAdapter')
.default;
const postgresURI =
'postgres://localhost:5432/parse_server_postgres_adapter_test_database';
const ParseServer = require('../lib/index');
const express = require('express');
//public schema
const databaseOptions1 = {
initOptions: {
schema: 'public'
}
schema: 'public',
},
};
//not exists schema
const databaseOptions2 = {
initOptions: {
schema: 'not_exists_schema'
}
schema: 'not_exists_schema',
},
};
const GameScore = Parse.Object.extend({
className: "GameScore"
className: 'GameScore',
});
function createParseServer(options) {
return new Promise((resolve, reject) => {
const parseServer = new ParseServer.default(Object.assign({},
defaultConfiguration, options, {
serverURL: "http://localhost:12666/parse",
const parseServer = new ParseServer.default(
Object.assign({}, defaultConfiguration, options, {
serverURL: 'http://localhost:12666/parse',
__indexBuildCompletionCallbackForTests: promise => {
promise
.then(() => {
expect(Parse.applicationId).toEqual("test");
const app = express();
app.use('/parse', parseServer.app);
promise.then(() => {
expect(Parse.applicationId).toEqual('test');
const app = express();
app.use('/parse', parseServer.app);
const server = app.listen(12666);
Parse.serverURL = "http://localhost:12666/parse";
resolve(server);
}, reject);
}}));
const server = app.listen(12666);
Parse.serverURL = 'http://localhost:12666/parse';
resolve(server);
}, reject);
},
})
);
});
}
@@ -48,27 +51,37 @@ describe_only_db('postgres')('Postgres database init options', () => {
if (server) {
server.close();
}
})
it('should create server with public schema databaseOptions', (done) => {
const adapter = new PostgresStorageAdapter({
uri: postgresURI, collectionPrefix: 'test_',
databaseOptions: databaseOptions1
})
createParseServer({ databaseAdapter: adapter }).then((newServer) => {
server = newServer;
const score = new GameScore({ "score": 1337, "playerName": "Sean Plott", "cheatMode": false });
return score.save();
}).then(done, done.fail);
});
it('should fail to create server if schema databaseOptions does not exist', (done) => {
it('should create server with public schema databaseOptions', done => {
const adapter = new PostgresStorageAdapter({
uri: postgresURI, collectionPrefix: 'test_',
databaseOptions: databaseOptions2
})
uri: postgresURI,
collectionPrefix: 'test_',
databaseOptions: databaseOptions1,
});
createParseServer({ databaseAdapter: adapter }).then(done.fail, () => done());
createParseServer({ databaseAdapter: adapter })
.then(newServer => {
server = newServer;
const score = new GameScore({
score: 1337,
playerName: 'Sean Plott',
cheatMode: false,
});
return score.save();
})
.then(done, done.fail);
});
it('should fail to create server if schema databaseOptions does not exist', done => {
const adapter = new PostgresStorageAdapter({
uri: postgresURI,
collectionPrefix: 'test_',
databaseOptions: databaseOptions2,
});
createParseServer({ databaseAdapter: adapter }).then(done.fail, () =>
done()
);
});
});