Skip to content

Commit 137dde5

Browse files
committed
added more tests, extended readme
1 parent 9b22226 commit 137dde5

File tree

4 files changed

+93
-10
lines changed

4 files changed

+93
-10
lines changed

README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ The crawler will fetch all sites matching folder URLs and certain file extension
1919

2020
**Tip**: Omit the URL protocol, the crawler will detect the right one.
2121

22-
### Options
22+
**Important**: Executing the w3c-validator with sites using HTML `base`-tag along with links *without* leading slashes will probably not work.
23+
24+
## Options
2325
```BASH
2426
$ w3c-validator --help
2527

@@ -29,9 +31,20 @@ $ w3c-validator --help
2931

3032
-h, --help output usage information
3133
-V, --version output the version number
34+
-l, --log log errors in a text file
3235
-q, --query consider query string
33-
-n, --nofollow validate single URL
3436
-v, --verbose show error details
3537
```
3638

37-
**Important**: Executing the w3c-validator with sites using HTML `base`-tag along with links *without* leading slashes will probably not work.
39+
40+
### log
41+
42+
Create a log file containing all invalid URL's including error details.
43+
44+
### query
45+
46+
Consider URLs with query strings like `http://www.example.com/?foo=bar` as indiviual sites and add them to the sitemap.
47+
48+
### verbose
49+
50+
Output additional error information in the console.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
},
4545
"devDependencies": {
4646
"chai": "^3.4.1",
47-
"mocha": "^2.3.4"
47+
"mocha": "^2.3.4",
48+
"del": "^2.1.0"
4849
}
4950
}

test/cli.js

Lines changed: 66 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,79 @@
11
var should = require("chai").should();
22
var exec = require("child_process").exec;
3+
var del = require("del");
4+
5+
require("./lib/testserver.js");
36

47
describe("$ w3c-validator invalid", function() {
5-
it("should fail because of invalid url");
6-
it("should exit with error code '1'");
8+
var _error;
9+
var _stdout;
10+
var _stderr;
11+
12+
before(function(done) {
13+
var cmd = exec("node ./lib/W3CValidator.js illegal", function(error, stdout, stderr) {
14+
_error = error;
15+
_stdout = stdout;
16+
_stderr = stderr;
17+
done();
18+
});
19+
});
20+
21+
it("should fail because of invalid url", function() {
22+
_stderr.should.not.be.empty;
23+
});
24+
25+
it("should exit with error code '1'", function() {
26+
_error.code.should.equal(1);
27+
});
728
});
829

930
describe("$ w3c-validator 127.0.0.1", function() {
10-
it("should not throw any errors");
11-
it("should return success message");
31+
this.timeout(10000);
32+
33+
var _error;
34+
var _stdout;
35+
var _stderr;
36+
37+
before(function(done) {
38+
var cmd = exec("node ./lib/W3CValidator.js 127.0.0.1", function(error, stdout, stderr) {
39+
_error = error;
40+
_stdout = stdout;
41+
_stderr = stderr;
42+
done();
43+
});
44+
});
45+
46+
it("should not throw any errors", function() {
47+
_stderr.should.be.empty;
48+
should.equal(_error, null);
49+
});
50+
51+
it("should return success message", function() {
52+
_stdout.should.not.be.empty;
53+
});
1254
});
1355

1456
describe("$ w3c-validator --log 127.0.0.1", function() {
15-
it("should create a text file");
57+
58+
var _error;
59+
var _stdout;
60+
var _stderr;
61+
62+
after(function() {
63+
del.sync(["./*.txt"])
64+
});
65+
66+
before(function(done) {
67+
var cmd = exec("node ./lib/W3CValidator.js --log", function(error, stdout, stderr) {
68+
_error = error;
69+
_stdout = stdout;
70+
_stderr = stderr;
71+
done();
72+
});
73+
});
74+
75+
it("should create a log file");
76+
1677
});
1778

1879
describe("$ w3c-validator --query 127.0.0.1", function() {

test/lib/routes.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
var http = require("http");
22

33
module.exports = {
4-
4+
"/": function(req, res) {
5+
res.writeHead(
6+
200,
7+
http.STATUS_CODES[200], {
8+
"Content-Type": "text/html"
9+
});
10+
res.write("");
11+
res.end();
12+
}
513
};

0 commit comments

Comments
 (0)