Skip to content

Commit 87ccf27

Browse files
committed
Update helper.js
1 parent 9d728ec commit 87ccf27

File tree

1 file changed

+36
-50
lines changed

1 file changed

+36
-50
lines changed

integration/test/helper.js

Lines changed: 36 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -97,38 +97,28 @@ const destroyAliveConnections = function () {
9797
let parseServer;
9898
let server;
9999

100-
const reconfigureServer = (changedConfiguration = {}) => {
101-
return new Promise((resolve, reject) => {
102-
if (server) {
103-
return parseServer.handleShutdown().then(() => {
104-
server.close(() => {
105-
parseServer = undefined;
106-
server = undefined;
107-
reconfigureServer(changedConfiguration).then(resolve, reject);
108-
});
100+
const reconfigureServer = async (changedConfiguration = {}) => {
101+
if (server) {
102+
return parseServer.handleShutdown().then(() => {
103+
server.close(() => {
104+
parseServer = undefined;
105+
server = undefined;
106+
return reconfigureServer(changedConfiguration);
109107
});
110-
}
111-
try {
112-
didChangeConfiguration = Object.keys(changedConfiguration).length !== 0;
113-
const newConfiguration = Object.assign({}, defaultConfiguration, changedConfiguration || {}, {
114-
serverStartComplete: error => {
115-
if (error) {
116-
reject(error);
117-
} else {
118-
resolve(parseServer);
119-
}
120-
},
121-
mountPath,
122-
port,
123-
});
124-
parseServer = ParseServer.start(newConfiguration);
125-
const app = parseServer.expressApp;
126-
for (const fileName of ['parse.js', 'parse.min.js']) {
127-
const file = fs
128-
.readFileSync(path.resolve(__dirname, `./../../dist/${fileName}`))
129-
.toString();
130-
app.get(`/${fileName}`, (req, res) => {
131-
res.send(`<html><head>
108+
});
109+
}
110+
111+
didChangeConfiguration = Object.keys(changedConfiguration).length !== 0;
112+
const newConfiguration = Object.assign({}, defaultConfiguration, changedConfiguration || {}, {
113+
mountPath,
114+
port,
115+
});
116+
parseServer = await ParseServer.startApp(newConfiguration);
117+
const app = parseServer.expressApp;
118+
for (const fileName of ['parse.js', 'parse.min.js']) {
119+
const file = fs.readFileSync(path.resolve(__dirname, `./../../dist/${fileName}`)).toString();
120+
app.get(`/${fileName}`, (req, res) => {
121+
res.send(`<html><head>
132122
<meta charset="utf-8">
133123
<meta http-equiv="X-UA-Compatible" content="IE=edge">
134124
<title>Parse Functionality Test</title>
@@ -142,25 +132,21 @@ const reconfigureServer = (changedConfiguration = {}) => {
142132
</head>
143133
<body>
144134
</body></html>`);
145-
});
146-
}
147-
app.get('/clear/:fast', (req, res) => {
148-
const { fast } = req.params;
149-
TestUtils.destroyAllDataPermanently(fast).then(() => {
150-
res.send('{}');
151-
});
152-
});
153-
server = parseServer.server;
154-
server.on('connection', connection => {
155-
const key = `${connection.remoteAddress}:${connection.remotePort}`;
156-
openConnections[key] = connection;
157-
connection.on('close', () => {
158-
delete openConnections[key];
159-
});
160-
});
161-
} catch (error) {
162-
reject(error);
163-
}
135+
});
136+
}
137+
app.get('/clear/:fast', (req, res) => {
138+
const { fast } = req.params;
139+
TestUtils.destroyAllDataPermanently(fast).then(() => {
140+
res.send('{}');
141+
});
142+
});
143+
server = parseServer.server;
144+
server.on('connection', connection => {
145+
const key = `${connection.remoteAddress}:${connection.remotePort}`;
146+
openConnections[key] = connection;
147+
connection.on('close', () => {
148+
delete openConnections[key];
149+
});
164150
});
165151
};
166152
global.DiffObject = Parse.Object.extend('DiffObject');

0 commit comments

Comments
 (0)