1- const execa = require ( 'execa' ) ;
21const Project = require ( './__utils__/fake-project' ) ;
2+ const { createBinTester } = require ( '@scalvert/bin-tester' ) ;
33
44describe ( 'SonarQube Formatter' , ( ) => {
55 let project ;
6+ let { setupProject, teardownProject, runBin } = createBinTester ( {
7+ binPath : require . resolve (
8+ '../node_modules/ember-template-lint/bin/ember-template-lint.js'
9+ ) ,
10+ staticArgs : [ '.' , '--format' , require . resolve ( '..' ) ] ,
11+ projectConstructor : Project ,
12+ } ) ;
613
7- beforeEach ( ( ) => {
8- project = new Project ( 'fake-project' ) ;
14+ beforeEach ( async ( ) => {
15+ project = await setupProject ( ) ;
916 } ) ;
1017
1118 afterEach ( ( ) => {
12- // project.dispose ();
19+ teardownProject ( ) ;
1320 } ) ;
1421
1522 it ( 'can format output from no results' , async ( ) => {
@@ -26,7 +33,7 @@ describe('SonarQube Formatter', () => {
2633 } ,
2734 } ) ;
2835
29- let result = await emberTemplateLint ( ) ;
36+ let result = await runBin ( ) ;
3037
3138 expect ( result . stdout ) . toMatchInlineSnapshot ( `
3239 "{
@@ -53,7 +60,7 @@ describe('SonarQube Formatter', () => {
5360 } ,
5461 } ) ;
5562
56- let result = await emberTemplateLint ( ) ;
63+ let result = await runBin ( ) ;
5764
5865 expect ( result . stdout ) . toMatchInlineSnapshot ( `
5966 "{
@@ -113,7 +120,7 @@ describe('SonarQube Formatter', () => {
113120 } ,
114121 } ) ;
115122
116- let result = await emberTemplateLint ( ) ;
123+ let result = await runBin ( ) ;
117124
118125 expect ( result . stdout ) . toMatchInlineSnapshot ( `
119126 "{
@@ -154,37 +161,4 @@ describe('SonarQube Formatter', () => {
154161 }"
155162 ` ) ;
156163 } ) ;
157-
158- function emberTemplateLint ( argumentsOrOptions , options ) {
159- if ( arguments . length > 0 ) {
160- if ( arguments . length === 1 ) {
161- options = Array . isArray ( argumentsOrOptions ) ? { } : argumentsOrOptions ;
162- }
163- } else {
164- argumentsOrOptions = [ ] ;
165- options = { } ;
166- }
167-
168- const mergedOptions = Object . assign (
169- {
170- reject : false ,
171- cwd : project . baseDir ,
172- } ,
173- options
174- ) ;
175-
176- return execa (
177- process . execPath ,
178- [
179- require . resolve (
180- '../node_modules/ember-template-lint/bin/ember-template-lint.js'
181- ) ,
182- '.' ,
183- '--format' ,
184- require . resolve ( '..' ) ,
185- ...argumentsOrOptions ,
186- ] ,
187- mergedOptions
188- ) ;
189- }
190164} ) ;
0 commit comments