@@ -2,7 +2,7 @@ import * as fs from 'fs'
2
2
import { expect } from 'chai'
3
3
import parse from 'eslint-module-utils/parse'
4
4
5
- import { getFilename } from '../utils'
5
+ import { getFilename , makeNaiveSpy } from '../utils'
6
6
7
7
describe ( 'parse(content, { settings, ecmaFeatures })' , function ( ) {
8
8
const path = getFilename ( 'jsx.js' )
@@ -21,4 +21,21 @@ describe('parse(content, { settings, ecmaFeatures })', function () {
21
21
. not . to . throw ( Error )
22
22
} )
23
23
24
+ it ( 'passes expected parserOptions to custom parser' , function ( ) {
25
+ const parseSpy = makeNaiveSpy ( )
26
+ const parserOptions = { ecmaFeatures : { jsx : true } }
27
+ require ( './parseStubParser' ) . parse = parseSpy
28
+ parse ( path , content , { settings : { } , parserPath : require . resolve ( './parseStubParser' ) , parserOptions : parserOptions } )
29
+ expect ( parseSpy . callCount ) . to . equal ( 1 )
30
+ expect ( parseSpy . lastCallArguments [ 0 ] ) . to . equal ( content )
31
+ expect ( parseSpy . lastCallArguments [ 1 ] ) . to . be . an ( 'object' )
32
+ expect ( parseSpy . lastCallArguments [ 1 ] ) . to . not . equal ( parserOptions )
33
+ expect ( parseSpy . lastCallArguments [ 1 ] )
34
+ . to . have . property ( 'ecmaFeatures' )
35
+ . that . is . eql ( parserOptions . ecmaFeatures )
36
+ . and . is . not . equal ( parserOptions . ecmaFeatures )
37
+ expect ( parseSpy . lastCallArguments [ 1 ] ) . to . have . property ( 'attachComment' , true )
38
+ expect ( parseSpy . lastCallArguments [ 1 ] ) . to . have . property ( 'filePath' , path )
39
+ } )
40
+
24
41
} )
0 commit comments