@@ -73,3 +73,47 @@ describe("About fixtures/hello.vue", () => {
7373 assert ( actual === expected )
7474 } )
7575} )
76+
77+ describe ( "About fixtures/notvue.js" , ( ) => {
78+ beforeEach ( ( ) => {
79+ fs . copySync ( ORIGINAL_FIXTURE_DIR , FIXTURE_DIR )
80+ } )
81+ afterEach ( ( ) => {
82+ fs . removeSync ( FIXTURE_DIR )
83+ } )
84+
85+ it ( "should notify a 'semi' error" , ( ) => {
86+ const cli = new CLIEngine ( {
87+ cwd : FIXTURE_DIR ,
88+ envs : [ "es6" , "node" ] ,
89+ parser : PARSER_PATH ,
90+ rules : { semi : "error" } ,
91+ useEslintrc : false ,
92+ } )
93+ const report = cli . executeOnFiles ( [ "notvue.js" ] )
94+ const messages = report . results [ 0 ] . messages
95+
96+ assert ( messages . length === 1 )
97+ assert ( messages [ 0 ] . ruleId === "semi" )
98+ assert ( messages [ 0 ] . line === 1 )
99+ assert ( messages [ 0 ] . column === 21 )
100+ assert ( messages [ 0 ] . source === "console.log(\"hello\")" )
101+ } )
102+
103+ it ( "should fix a 'semi' error with --fix option" , ( ) => {
104+ const cli = new CLIEngine ( {
105+ cwd : FIXTURE_DIR ,
106+ envs : [ "es6" , "node" ] ,
107+ fix : true ,
108+ parser : PARSER_PATH ,
109+ rules : { semi : "error" } ,
110+ useEslintrc : false ,
111+ } )
112+ CLIEngine . outputFixes ( cli . executeOnFiles ( [ "notvue.js" ] ) )
113+
114+ const actual = fs . readFileSync ( path . join ( FIXTURE_DIR , "notvue.js" ) , "utf8" )
115+ const expected = fs . readFileSync ( path . join ( FIXTURE_DIR , "notvue.js.fixed" ) , "utf8" )
116+
117+ assert ( actual === expected )
118+ } )
119+ } )
0 commit comments