Skip to content

Commit 35ae229

Browse files
Formats test support files
1 parent c9d7a9b commit 35ae229

File tree

3 files changed

+30
-29
lines changed

3 files changed

+30
-29
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"main": "lib/index.js",
1010
"scripts": {
1111
"eslint": "eslint lib test valimate.js",
12-
"format": "prettier --write 'lib/**/*.js'",
12+
"format": "prettier --write 'test/**/*.js' valimate.js 'lib/**/*.js'",
1313
"test": "npm run eslint && npm run test-e2e && istanbul cover _mocha --report lcovonly",
1414
"test-and-report-coverage": "npm test && cat coverage/lcov.info | coveralls",
1515
"test-e2e": "./valimate.js"

test/init.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
global.sinon = require('sinon');
44
global.chai = require('chai');
5-
global.expect = global.chai.expect;
5+
global.expect = global.chai.expect;

test/testServer.js

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,42 +21,43 @@ const HTML = `
2121
`;
2222

2323
function sendHtml(res) {
24-
res.end(HTML, 'utf-8');
24+
res.end(HTML, 'utf-8');
2525
}
2626

2727
function redirect(res, statusCode) {
28-
res.writeHead(statusCode, {
29-
Location: '/',
30-
});
28+
res.writeHead(statusCode, {
29+
Location: '/'
30+
});
3131

32-
res.end();
32+
res.end();
3333
}
3434

3535
function assertEnvVariable() {
36-
const expectedValue = 'true';
36+
const expectedValue = 'true';
3737

38-
if (!process.env.TEST || process.env.TEST !== expectedValue) {
39-
throw new Error(`Expect process.env.TEST to be ${expectedValue}!`)
40-
}
38+
if (!process.env.TEST || process.env.TEST !== expectedValue) {
39+
throw new Error(`Expect process.env.TEST to be ${expectedValue}!`);
40+
}
4141
}
4242

4343
assertEnvVariable();
4444

45-
http.createServer((req, res) => {
46-
switch (req.url) {
47-
case '/301-redirect':
48-
redirect(res, 301);
49-
break;
50-
51-
case '/302-redirect':
52-
redirect(res, 302);
53-
break;
54-
55-
default:
56-
sendHtml(res);
57-
}
58-
59-
}).listen(PORT, () => {
60-
console.log(`Test server listening on ${PORT}...`);
61-
notifyValimate(true);
62-
});
45+
http
46+
.createServer((req, res) => {
47+
switch (req.url) {
48+
case '/301-redirect':
49+
redirect(res, 301);
50+
break;
51+
52+
case '/302-redirect':
53+
redirect(res, 302);
54+
break;
55+
56+
default:
57+
sendHtml(res);
58+
}
59+
})
60+
.listen(PORT, () => {
61+
console.log(`Test server listening on ${PORT}...`);
62+
notifyValimate(true);
63+
});

0 commit comments

Comments
 (0)