-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcli.js
71 lines (57 loc) · 1.48 KB
/
cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* globals it:false, before:false, describe:false */
/* eslint no-unused-expressions: 0 */
/* eslint-env node, mocha */
var should = require('chai').should();
var exec = require('child_process').exec;
var del = require('del');
require('./lib/testserver.js');
describe('$ w3c-validator invalid', function () {
var _error;
var _stderr;
before(function (done) {
exec('node ./cli.js illegal', function cmd(error, stdout, stderr) {
_error = error;
_stderr = stderr;
done();
});
});
it('should fail because of invalid url', function () {
_stderr.should.not.be.empty;
});
it('should exit with error code "1"', function () {
_error.code.should.equal(1);
});
});
describe('$ w3c-validator 127.0.0.1', function () {
var _error;
var _stdout;
var _stderr;
this.timeout(10000);
before(function (done) {
exec('node ./cli.js 127.0.0.1', function cmd(error, stdout, stderr) {
_error = error;
_stdout = stdout;
_stderr = stderr;
done();
});
});
it('should not throw any errors', function () {
_stderr.should.be.empty;
should.equal(_error, null);
});
it('should return success message', function () {
_stdout.should.not.be.empty;
});
});
describe('$ w3c-validator --log 127.0.0.1', function () {
after(function () {
del.sync(['./*.txt']);
});
before(function (done) {
exec('node ./cli.js --log', function cmd() {
done();
});
});
// @TODO:
it('should create a log file');
});