-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test to ensure port, config, appId, serverURL, masterKey, appName…
…, graphQLServerURL options are not ignored.
- Loading branch information
Showing
3 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"plugins": [ | ||
"jest" | ||
], | ||
"env": { | ||
"jest/globals": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
const path = require('path'); | ||
const spawn = require('child_process').spawn; | ||
|
||
const TIMEOUT = 1000; // ms | ||
|
||
describe('port, config, appId, serverURL, masterKey, appName, graphQLServerURL options should not be ignored.', () => { | ||
it('Should start with port 4041.', async () => { | ||
const result = await startParseDashboardAndGetOutput(['--port', '4041']); | ||
|
||
expect(result).toContain('The dashboard is now available at http://0.0.0.0:4041/'); | ||
}); | ||
|
||
it('Should return an error message if config and appId options are provided together.', async () => { | ||
const result = await startParseDashboardAndGetOutput(['--config', 'helloworld', '--appId', 'helloworld']); | ||
|
||
expect(result).toContain('You must provide either a config file or other CLI options (appName, appId, masterKey, serverURL, and graphQLServerURL); not both.'); | ||
}); | ||
|
||
it('Should return an error message if config and serverURL options are provided together.', async () => { | ||
const result = await startParseDashboardAndGetOutput(['--config', 'helloworld', '--serverURL', 'helloworld']); | ||
|
||
expect(result).toContain('You must provide either a config file or other CLI options (appName, appId, masterKey, serverURL, and graphQLServerURL); not both.'); | ||
}); | ||
|
||
it('Should return an error message if config and masterKey options are provided together.', async () => { | ||
const result = await startParseDashboardAndGetOutput(['--config', 'helloworld', '--masterKey', 'helloworld']); | ||
|
||
expect(result).toContain('You must provide either a config file or other CLI options (appName, appId, masterKey, serverURL, and graphQLServerURL); not both.'); | ||
}); | ||
|
||
it('Should return an error message if config and appName options are provided together.', async () => { | ||
const result = await startParseDashboardAndGetOutput(['--config', 'helloworld', '--appName', 'helloworld']); | ||
|
||
expect(result).toContain('You must provide either a config file or other CLI options (appName, appId, masterKey, serverURL, and graphQLServerURL); not both.'); | ||
}); | ||
|
||
it('Should return an error message if config and graphQLServerURL options are provided together.', async () => { | ||
const result = await startParseDashboardAndGetOutput(['--config', 'helloworld', '--graphQLServerURL', 'helloworld']); | ||
|
||
expect(result).toContain('You must provide either a config file or other CLI options (appName, appId, masterKey, serverURL, and graphQLServerURL); not both.'); | ||
}); | ||
}); | ||
|
||
function startParseDashboardAndGetOutput(args) { | ||
return new Promise((resolve) => { | ||
const indexFilePath = path.resolve('./Parse-Dashboard/index.js'); | ||
const child = spawn('node', [indexFilePath, ...args], { cwd: '.', timeout: TIMEOUT, killSignal: 'SIGINT' }); | ||
|
||
let output = ''; | ||
child.on('error', () => { resolve(output); }); | ||
child.on('close', () => { resolve(output); }); | ||
|
||
if (child.stdout) { | ||
child.stdout.on('data', data => { | ||
output += `STDOUT: ${data}\n`; | ||
}); | ||
} | ||
|
||
if (child.stderr) { | ||
child.stderr.on('data', data => { | ||
output += `STDERROR: ${data}\n`; | ||
}); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters