Skip to content

Commit

Permalink
CLI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davimacedo committed Jun 20, 2019
1 parent bffde92 commit ae3f43c
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions spec/CLI.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ const commander = require('../lib/cli/utils/commander').default;
const definitions = require('../lib/cli/definitions/parse-server').default;
const liveQueryDefinitions = require('../lib/cli/definitions/parse-live-query-server')
.default;
const path = require('path');
const { spawn } = require('child_process');

const testDefinitions = {
arg0: 'PROGRAM_ARG_0',
Expand Down Expand Up @@ -231,3 +233,84 @@ describe('LiveQuery definitions', () => {
}
});
});

describe('execution', () => {
const binPath = path.resolve(__dirname, '../bin/parse-server');
let childProcess;

afterEach(async () => {
if (childProcess) {
childProcess.kill();
}
});

it('shoud start Parse Server', done => {
childProcess = spawn(binPath, [
'--appId',
'test',
'--masterKey',
'test',
'--databaseURI',
'mongodb://localhost/test',
]);
childProcess.stdout.on('data', data => {
data = data.toString();
if (data.includes('parse-server running on')) {
done();
}
});
childProcess.stderr.on('data', data => {
done.fail(data.toString());
});
});

it('shoud start Parse Server with GraphQL', done => {
childProcess = spawn(binPath, [
'--appId',
'test',
'--masterKey',
'test',
'--databaseURI',
'mongodb://localhost/test',
'--mountGraphQL',
]);
let output = '';
childProcess.stdout.on('data', data => {
data = data.toString();
output += data;
if (data.includes('GraphQL running on')) {
expect(output).toMatch('parse-server running on');
done();
}
});
childProcess.stderr.on('data', data => {
done.fail(data.toString());
});
});

it('shoud start Parse Server with GraphQL and Playground', done => {
childProcess = spawn(binPath, [
'--appId',
'test',
'--masterKey',
'test',
'--databaseURI',
'mongodb://localhost/test',
'--mountGraphQL',
'--mountPlayground',
]);
let output = '';
childProcess.stdout.on('data', data => {
data = data.toString();
output += data;
if (data.includes('Playground running on')) {
expect(output).toMatch('GraphQL running on');
expect(output).toMatch('parse-server running on');
done();
}
});
childProcess.stderr.on('data', data => {
done.fail(data.toString());
});
});
});

0 comments on commit ae3f43c

Please sign in to comment.