1 | 'use strict';
|
2 |
|
3 | var waitOn = require('../');
|
4 | var childProcess = require('child_process');
|
5 |
|
6 | var mocha = require('mocha');
|
7 | var describe = mocha.describe;
|
8 | var it = mocha.it;
|
9 | var expect = require('expect');
|
10 |
|
11 | function execCLI(args, options) {
|
12 | return childProcess.exec('../bin/wait-on', args, options);
|
13 | }
|
14 |
|
15 |
|
16 | describe('validation', function () {
|
17 |
|
18 | describe('API', function () {
|
19 | it('should return error when no resources are provided', function (done) {
|
20 | var opts = {};
|
21 | waitOn(opts, function (err) {
|
22 | expect(err).toExist();
|
23 | done();
|
24 | });
|
25 | });
|
26 |
|
27 | it('should return error when opts is null', function (done) {
|
28 | waitOn(null, function (err) {
|
29 | expect(err).toExist();
|
30 | done();
|
31 | });
|
32 | });
|
33 |
|
34 | });
|
35 |
|
36 | describe('CLI', function () {
|
37 | it('should exit with non-zero error code when no resources provided', function (done) {
|
38 | execCLI([])
|
39 | .on('exit', function (code) {
|
40 | expect(code).toNotBe(0);
|
41 | done();
|
42 | });
|
43 | });
|
44 | });
|
45 |
|
46 | });
|