@@ -4,11 +4,12 @@ import {assert} from 'chai';
4
4
import sinon from 'sinon' ;
5
5
6
6
import defaultLintCommand from '../../src/cmd/lint' ;
7
- import { makeSureItFails } from '../helpers' ;
7
+ import { FileFilter } from '../../src/cmd/build' ;
8
+ import { fake , makeSureItFails } from '../helpers' ;
8
9
9
10
describe ( 'lint' , ( ) => {
10
11
11
- function setUp ( { createLinter} = { } ) {
12
+ function setUp ( { createLinter, fileFilter } : Object = { } ) {
12
13
const lintResult = '<lint.run() result placeholder>' ;
13
14
const runLinter = sinon . spy ( ( ) => Promise . resolve ( lintResult ) ) ;
14
15
if ( ! createLinter ) {
@@ -21,7 +22,7 @@ describe('lint', () => {
21
22
createLinter,
22
23
runLinter,
23
24
lint : ( { ...args } ) => {
24
- return defaultLintCommand ( args , { createLinter} ) ;
25
+ return defaultLintCommand ( args , { createLinter, fileFilter } ) ;
25
26
} ,
26
27
} ;
27
28
}
@@ -99,4 +100,20 @@ describe('lint', () => {
99
100
} ) ;
100
101
} ) ;
101
102
103
+ it ( 'passes a file filter to the linter' , ( ) => {
104
+ const fileFilter = fake ( new FileFilter ( ) ) ;
105
+ const { lint, createLinter} = setUp ( { fileFilter} ) ;
106
+ return lint ( )
107
+ . then ( ( ) => {
108
+ assert . equal ( createLinter . called , true ) ;
109
+ const config = createLinter . firstCall . args [ 0 ] . config ;
110
+ assert . isFunction ( config . shouldScanFile ) ;
111
+
112
+ // Simulate how the linter will use this callback.
113
+ config . shouldScanFile ( 'manifest.json' ) ;
114
+ assert . equal ( fileFilter . wantFile . called , true ) ;
115
+ assert . equal ( fileFilter . wantFile . firstCall . args [ 0 ] , 'manifest.json' ) ;
116
+ } ) ;
117
+ } ) ;
118
+
102
119
} ) ;
0 commit comments