@@ -7,6 +7,8 @@ import { getFilename } from '../utils'
7
7
8
8
describe ( 'parse(content, { settings, ecmaFeatures })' , function ( ) {
9
9
const path = getFilename ( 'jsx.js' )
10
+ const parseStubParser = require ( './parseStubParser' )
11
+ const parseStubParserPath = require . resolve ( './parseStubParser' )
10
12
let content
11
13
12
14
before ( ( done ) =>
@@ -25,8 +27,8 @@ describe('parse(content, { settings, ecmaFeatures })', function () {
25
27
it ( 'passes expected parserOptions to custom parser' , function ( ) {
26
28
const parseSpy = sinon . spy ( )
27
29
const parserOptions = { ecmaFeatures : { jsx : true } }
28
- require ( './ parseStubParser' ) . parse = parseSpy
29
- parse ( path , content , { settings : { } , parserPath : require . resolve ( './parseStubParser' ) , parserOptions : parserOptions } )
30
+ parseStubParser . parse = parseSpy
31
+ parse ( path , content , { settings : { } , parserPath : parseStubParserPath , parserOptions : parserOptions } )
30
32
expect ( parseSpy . callCount , 'custom parser to be called once' ) . to . equal ( 1 )
31
33
expect ( parseSpy . args [ 0 ] [ 0 ] , 'custom parser to get content as its first argument' ) . to . equal ( content )
32
34
expect ( parseSpy . args [ 0 ] [ 1 ] , 'custom parser to get an object as its second argument' ) . to . be . an ( 'object' )
@@ -50,8 +52,8 @@ describe('parse(content, { settings, ecmaFeatures })', function () {
50
52
it ( 'should take the alternate parser specified in settings' , function ( ) {
51
53
const parseSpy = sinon . spy ( )
52
54
const parserOptions = { ecmaFeatures : { jsx : true } }
53
- require ( './ parseStubParser' ) . parse = parseSpy
54
- expect ( parse . bind ( null , path , content , { settings : { 'import/parsers' : { [ require . resolve ( './parseStubParser' ) ] : [ '.js' ] } } , parserPath : null , parserOptions : parserOptions } ) ) . not . to . throw ( Error )
55
+ parseStubParser . parse = parseSpy
56
+ expect ( parse . bind ( null , path , content , { settings : { 'import/parsers' : { [ parseStubParserPath ] : [ '.js' ] } } , parserPath : null , parserOptions : parserOptions } ) ) . not . to . throw ( Error )
55
57
expect ( parseSpy . callCount , 'custom parser to be called once' ) . to . equal ( 1 )
56
58
} )
57
59
0 commit comments