File tree Expand file tree Collapse file tree 3 files changed +30
-29
lines changed Expand file tree Collapse file tree 3 files changed +30
-29
lines changed Original file line number Diff line number Diff line change 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"
Original file line number Diff line number Diff line change 22
33global . sinon = require ( 'sinon' ) ;
44global . chai = require ( 'chai' ) ;
5- global . expect = global . chai . expect ;
5+ global . expect = global . chai . expect ;
Original file line number Diff line number Diff line change @@ -21,42 +21,43 @@ const HTML = `
2121` ;
2222
2323function sendHtml ( res ) {
24- res . end ( HTML , 'utf-8' ) ;
24+ res . end ( HTML , 'utf-8' ) ;
2525}
2626
2727function 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
3535function 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
4343assertEnvVariable ( ) ;
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+ } ) ;
You can’t perform that action at this time.
0 commit comments