11// Mocha Specification Cases
22
33// Imports
4- const fs = require ( 'fs' ) ;
5- const should = require ( 'should' ) ;
6- const Vinyl = require ( 'vinyl' ) ;
4+ import { readdirSync , readFileSync } from 'fs' ;
5+ import should from 'should' ;
6+ import Vinyl from 'vinyl' ;
77
88// Plugin
9- const htmlValidator = require ( '../html-validator.js' ) ;
9+ import { htmlValidator } from '../html-validator.js' ;
1010console . log ( ' Input HTML files for validation:' ) ;
11- fs . readdirSync ( 'spec/html' ) . forEach ( file => console . log ( ' spec/html/' + file ) ) ;
11+ readdirSync ( 'spec/html' ) . forEach ( file => console . log ( ' spec/html/' + file ) ) ;
1212
1313////////////////////////////////////////////////////////////////////////////////////////////////////
1414describe ( 'The gulp-w3c-html-validator plugin' , ( ) => {
@@ -19,10 +19,10 @@ describe('The gulp-w3c-html-validator plugin', () => {
1919 path : 'spec/html/valid.html' ,
2020 cwd : 'spec/' ,
2121 base : 'spec/html/' ,
22- contents : fs . readFileSync ( 'spec/html/valid.html' )
22+ contents : readFileSync ( 'spec/html/valid.html' )
2323 } ;
2424 const mockFile = new Vinyl ( vinylOptions ) ;
25- const stream = htmlValidator ( ) ;
25+ const stream = htmlValidator . analyzer ( ) ;
2626 const handleFileFromStream = ( file ) => {
2727 should . exist ( file ) ;
2828 file . w3cjs . success . should . equal ( true ) ;
@@ -51,10 +51,10 @@ describe('The gulp-w3c-html-validator plugin', () => {
5151 path : 'spec/html/invalid.html' ,
5252 cwd : 'spec/' ,
5353 base : 'spec/html/' ,
54- contents : fs . readFileSync ( 'spec/html/invalid.html' )
54+ contents : readFileSync ( 'spec/html/invalid.html' )
5555 } ;
5656 const mockFile = new Vinyl ( vinylOptions ) ;
57- const stream = htmlValidator ( ) ;
57+ const stream = htmlValidator . analyzer ( ) ;
5858 const handleFileFromStream = ( file ) => {
5959 should . exist ( file ) ;
6060 file . w3cjs . success . should . equal ( false ) ;
@@ -89,12 +89,12 @@ describe('The verifyMessage option', () => {
8989 path : 'spec/html/invalid.html' ,
9090 cwd : 'spec/' ,
9191 base : 'spec/html/' ,
92- contents : fs . readFileSync ( 'spec/html/invalid.html' )
92+ contents : readFileSync ( 'spec/html/invalid.html' )
9393 } ;
9494 const mockFile = new Vinyl ( vinylOptions ) ;
9595 const ignore = / ^ E l e m e n t .b l o c k q u o t e . n o t a l l o w e d a s c h i l d o f e l e m e n t / ;
9696 const verifyMessage = ( type , message ) => ! ignore . test ( message ) ;
97- const stream = htmlValidator ( { verifyMessage : verifyMessage , skipWarnings : true } ) ;
97+ const stream = htmlValidator . analyzer ( { verifyMessage : verifyMessage , skipWarnings : true } ) ;
9898 const handleFileFromStream = ( file ) => {
9999 should . exist ( file ) ;
100100 file . w3cjs . success . should . equal ( true ) ;
@@ -131,7 +131,7 @@ describe('The htmlValidator.reporter() function', () => {
131131 path : 'spec/html/valid.html' ,
132132 cwd : 'spec/' ,
133133 base : 'spec/html/' ,
134- contents : fs . readFileSync ( 'spec/html/valid.html' )
134+ contents : readFileSync ( 'spec/html/valid.html' )
135135 } ;
136136 const mockFile = new Vinyl ( vinylOptions ) ;
137137 const stream = htmlValidator . reporter ( ) ;
@@ -145,7 +145,7 @@ describe('The htmlValidator.reporter() function', () => {
145145 path : 'spec/html/invalid.html' ,
146146 cwd : 'spec/' ,
147147 base : 'spec/html/' ,
148- contents : fs . readFileSync ( 'spec/html/invalid.html' )
148+ contents : readFileSync ( 'spec/html/invalid.html' )
149149 } ;
150150 const mockFile = new Vinyl ( vinylOptions ) ;
151151 mockFile . w3cjs = {
@@ -154,7 +154,7 @@ describe('The htmlValidator.reporter() function', () => {
154154 } ;
155155 const stream = htmlValidator . reporter ( ) ;
156156 const writeToStream = ( ) => stream . write ( mockFile ) ;
157- ( writeToStream ) . should . throw ( / H T M L v a l i d a t i o n f a i l e d / ) ;
157+ writeToStream . should . throw ( / H T M L v a l i d a t i o n f a i l e d / ) ;
158158 stream . end ( ) ;
159159 return stream ;
160160 } ) ;
0 commit comments