@@ -4,7 +4,7 @@ import sinon from 'sinon';
4
4
import eslintPkg from 'eslint/package.json' ;
5
5
import typescriptPkg from 'typescript/package.json' ;
6
6
import * as tsConfigLoader from 'tsconfig-paths/lib/tsconfig-loader' ;
7
- import ExportMap from '../../../src/exportMapBuilder' ;
7
+ import ExportMapBuilder from '../../../src/exportMapBuilder' ;
8
8
9
9
import * as fs from 'fs' ;
10
10
@@ -28,7 +28,7 @@ describe('ExportMap', function () {
28
28
it ( 'handles ExportAllDeclaration' , function ( ) {
29
29
let imports ;
30
30
expect ( function ( ) {
31
- imports = ExportMap . get ( './export-all' , fakeContext ) ;
31
+ imports = ExportMapBuilder . get ( './export-all' , fakeContext ) ;
32
32
} ) . not . to . throw ( Error ) ;
33
33
34
34
expect ( imports ) . to . exist ;
@@ -37,41 +37,41 @@ describe('ExportMap', function () {
37
37
} ) ;
38
38
39
39
it ( 'returns a cached copy on subsequent requests' , function ( ) {
40
- expect ( ExportMap . get ( './named-exports' , fakeContext ) )
41
- . to . exist . and . equal ( ExportMap . get ( './named-exports' , fakeContext ) ) ;
40
+ expect ( ExportMapBuilder . get ( './named-exports' , fakeContext ) )
41
+ . to . exist . and . equal ( ExportMapBuilder . get ( './named-exports' , fakeContext ) ) ;
42
42
} ) ;
43
43
44
44
it ( 'does not return a cached copy after modification' , ( done ) => {
45
- const firstAccess = ExportMap . get ( './mutator' , fakeContext ) ;
45
+ const firstAccess = ExportMapBuilder . get ( './mutator' , fakeContext ) ;
46
46
expect ( firstAccess ) . to . exist ;
47
47
48
48
// mutate (update modified time)
49
49
const newDate = new Date ( ) ;
50
50
fs . utimes ( getFilename ( 'mutator.js' ) , newDate , newDate , ( error ) => {
51
51
expect ( error ) . not . to . exist ;
52
- expect ( ExportMap . get ( './mutator' , fakeContext ) ) . not . to . equal ( firstAccess ) ;
52
+ expect ( ExportMapBuilder . get ( './mutator' , fakeContext ) ) . not . to . equal ( firstAccess ) ;
53
53
done ( ) ;
54
54
} ) ;
55
55
} ) ;
56
56
57
57
it ( 'does not return a cached copy with different settings' , ( ) => {
58
- const firstAccess = ExportMap . get ( './named-exports' , fakeContext ) ;
58
+ const firstAccess = ExportMapBuilder . get ( './named-exports' , fakeContext ) ;
59
59
expect ( firstAccess ) . to . exist ;
60
60
61
61
const differentSettings = {
62
62
...fakeContext ,
63
63
parserPath : 'espree' ,
64
64
} ;
65
65
66
- expect ( ExportMap . get ( './named-exports' , differentSettings ) )
66
+ expect ( ExportMapBuilder . get ( './named-exports' , differentSettings ) )
67
67
. to . exist . and
68
68
. not . to . equal ( firstAccess ) ;
69
69
} ) ;
70
70
71
71
it ( 'does not throw for a missing file' , function ( ) {
72
72
let imports ;
73
73
expect ( function ( ) {
74
- imports = ExportMap . get ( './does-not-exist' , fakeContext ) ;
74
+ imports = ExportMapBuilder . get ( './does-not-exist' , fakeContext ) ;
75
75
} ) . not . to . throw ( Error ) ;
76
76
77
77
expect ( imports ) . not . to . exist ;
@@ -81,7 +81,7 @@ describe('ExportMap', function () {
81
81
it ( 'exports explicit names for a missing file in exports' , function ( ) {
82
82
let imports ;
83
83
expect ( function ( ) {
84
- imports = ExportMap . get ( './exports-missing' , fakeContext ) ;
84
+ imports = ExportMapBuilder . get ( './exports-missing' , fakeContext ) ;
85
85
} ) . not . to . throw ( Error ) ;
86
86
87
87
expect ( imports ) . to . exist ;
@@ -92,7 +92,7 @@ describe('ExportMap', function () {
92
92
it ( 'finds exports for an ES7 module with babel-eslint' , function ( ) {
93
93
const path = getFilename ( 'jsx/FooES7.js' ) ;
94
94
const contents = fs . readFileSync ( path , { encoding : 'utf8' } ) ;
95
- const imports = ExportMap . parse (
95
+ const imports = ExportMapBuilder . parse (
96
96
path ,
97
97
contents ,
98
98
{ parserPath : 'babel-eslint' , settings : { } } ,
@@ -112,7 +112,7 @@ describe('ExportMap', function () {
112
112
before ( 'parse file' , function ( ) {
113
113
const path = getFilename ( 'deprecated.js' ) ;
114
114
const contents = fs . readFileSync ( path , { encoding : 'utf8' } ) . replace ( / [ \r ] \n / g, lineEnding ) ;
115
- imports = ExportMap . parse ( path , contents , parseContext ) ;
115
+ imports = ExportMapBuilder . parse ( path , contents , parseContext ) ;
116
116
117
117
// sanity checks
118
118
expect ( imports . errors ) . to . be . empty ;
@@ -181,7 +181,7 @@ describe('ExportMap', function () {
181
181
before ( 'parse file' , function ( ) {
182
182
const path = getFilename ( 'deprecated-file.js' ) ;
183
183
const contents = fs . readFileSync ( path , { encoding : 'utf8' } ) ;
184
- imports = ExportMap . parse ( path , contents , parseContext ) ;
184
+ imports = ExportMapBuilder . parse ( path , contents , parseContext ) ;
185
185
186
186
// sanity checks
187
187
expect ( imports . errors ) . to . be . empty ;
@@ -243,7 +243,7 @@ describe('ExportMap', function () {
243
243
it ( 'works with espree & traditional namespace exports' , function ( ) {
244
244
const path = getFilename ( 'deep/a.js' ) ;
245
245
const contents = fs . readFileSync ( path , { encoding : 'utf8' } ) ;
246
- const a = ExportMap . parse ( path , contents , espreeContext ) ;
246
+ const a = ExportMapBuilder . parse ( path , contents , espreeContext ) ;
247
247
expect ( a . errors ) . to . be . empty ;
248
248
expect ( a . get ( 'b' ) . namespace ) . to . exist ;
249
249
expect ( a . get ( 'b' ) . namespace . has ( 'c' ) ) . to . be . true ;
@@ -252,7 +252,7 @@ describe('ExportMap', function () {
252
252
it ( 'captures namespace exported as default' , function ( ) {
253
253
const path = getFilename ( 'deep/default.js' ) ;
254
254
const contents = fs . readFileSync ( path , { encoding : 'utf8' } ) ;
255
- const def = ExportMap . parse ( path , contents , espreeContext ) ;
255
+ const def = ExportMapBuilder . parse ( path , contents , espreeContext ) ;
256
256
expect ( def . errors ) . to . be . empty ;
257
257
expect ( def . get ( 'default' ) . namespace ) . to . exist ;
258
258
expect ( def . get ( 'default' ) . namespace . has ( 'c' ) ) . to . be . true ;
@@ -261,7 +261,7 @@ describe('ExportMap', function () {
261
261
it ( 'works with babel-eslint & ES7 namespace exports' , function ( ) {
262
262
const path = getFilename ( 'deep-es7/a.js' ) ;
263
263
const contents = fs . readFileSync ( path , { encoding : 'utf8' } ) ;
264
- const a = ExportMap . parse ( path , contents , babelContext ) ;
264
+ const a = ExportMapBuilder . parse ( path , contents , babelContext ) ;
265
265
expect ( a . errors ) . to . be . empty ;
266
266
expect ( a . get ( 'b' ) . namespace ) . to . exist ;
267
267
expect ( a . get ( 'b' ) . namespace . has ( 'c' ) ) . to . be . true ;
@@ -278,7 +278,7 @@ describe('ExportMap', function () {
278
278
279
279
const path = getFilename ( 'deep/cache-1.js' ) ;
280
280
const contents = fs . readFileSync ( path , { encoding : 'utf8' } ) ;
281
- a = ExportMap . parse ( path , contents , espreeContext ) ;
281
+ a = ExportMapBuilder . parse ( path , contents , espreeContext ) ;
282
282
expect ( a . errors ) . to . be . empty ;
283
283
284
284
expect ( a . get ( 'b' ) . namespace ) . to . exist ;
@@ -304,25 +304,25 @@ describe('ExportMap', function () {
304
304
context ( 'Map API' , function ( ) {
305
305
context ( '#size' , function ( ) {
306
306
307
- it ( 'counts the names' , ( ) => expect ( ExportMap . get ( './named-exports' , fakeContext ) )
307
+ it ( 'counts the names' , ( ) => expect ( ExportMapBuilder . get ( './named-exports' , fakeContext ) )
308
308
. to . have . property ( 'size' , 12 ) ) ;
309
309
310
- it ( 'includes exported namespace size' , ( ) => expect ( ExportMap . get ( './export-all' , fakeContext ) )
310
+ it ( 'includes exported namespace size' , ( ) => expect ( ExportMapBuilder . get ( './export-all' , fakeContext ) )
311
311
. to . have . property ( 'size' , 1 ) ) ;
312
312
313
313
} ) ;
314
314
} ) ;
315
315
316
316
context ( 'issue #210: self-reference' , function ( ) {
317
317
it ( `doesn't crash` , function ( ) {
318
- expect ( ( ) => ExportMap . get ( './narcissist' , fakeContext ) ) . not . to . throw ( Error ) ;
318
+ expect ( ( ) => ExportMapBuilder . get ( './narcissist' , fakeContext ) ) . not . to . throw ( Error ) ;
319
319
} ) ;
320
320
it ( `'has' circular reference` , function ( ) {
321
- expect ( ExportMap . get ( './narcissist' , fakeContext ) )
321
+ expect ( ExportMapBuilder . get ( './narcissist' , fakeContext ) )
322
322
. to . exist . and . satisfy ( ( m ) => m . has ( 'soGreat' ) ) ;
323
323
} ) ;
324
324
it ( `can 'get' circular reference` , function ( ) {
325
- expect ( ExportMap . get ( './narcissist' , fakeContext ) )
325
+ expect ( ExportMapBuilder . get ( './narcissist' , fakeContext ) )
326
326
. to . exist . and . satisfy ( ( m ) => m . get ( 'soGreat' ) != null ) ;
327
327
} ) ;
328
328
} ) ;
@@ -335,7 +335,7 @@ describe('ExportMap', function () {
335
335
336
336
let imports ;
337
337
before ( 'load imports' , function ( ) {
338
- imports = ExportMap . get ( './typescript.ts' , context ) ;
338
+ imports = ExportMapBuilder . get ( './typescript.ts' , context ) ;
339
339
} ) ;
340
340
341
341
it ( 'returns nothing for a TypeScript file' , function ( ) {
@@ -372,7 +372,7 @@ describe('ExportMap', function () {
372
372
before ( 'load imports' , function ( ) {
373
373
this . timeout ( 20e3 ) ; // takes a long time :shrug:
374
374
sinon . spy ( tsConfigLoader , 'tsConfigLoader' ) ;
375
- imports = ExportMap . get ( './typescript.ts' , context ) ;
375
+ imports = ExportMapBuilder . get ( './typescript.ts' , context ) ;
376
376
} ) ;
377
377
after ( 'clear spies' , function ( ) {
378
378
tsConfigLoader . tsConfigLoader . restore ( ) ;
@@ -414,9 +414,9 @@ describe('ExportMap', function () {
414
414
} ,
415
415
} ;
416
416
expect ( tsConfigLoader . tsConfigLoader . callCount ) . to . equal ( 0 ) ;
417
- ExportMap . parse ( './baz.ts' , 'export const baz = 5' , customContext ) ;
417
+ ExportMapBuilder . parse ( './baz.ts' , 'export const baz = 5' , customContext ) ;
418
418
expect ( tsConfigLoader . tsConfigLoader . callCount ) . to . equal ( 1 ) ;
419
- ExportMap . parse ( './baz.ts' , 'export const baz = 5' , customContext ) ;
419
+ ExportMapBuilder . parse ( './baz.ts' , 'export const baz = 5' , customContext ) ;
420
420
expect ( tsConfigLoader . tsConfigLoader . callCount ) . to . equal ( 1 ) ;
421
421
422
422
const differentContext = {
@@ -426,17 +426,17 @@ describe('ExportMap', function () {
426
426
} ,
427
427
} ;
428
428
429
- ExportMap . parse ( './baz.ts' , 'export const baz = 5' , differentContext ) ;
429
+ ExportMapBuilder . parse ( './baz.ts' , 'export const baz = 5' , differentContext ) ;
430
430
expect ( tsConfigLoader . tsConfigLoader . callCount ) . to . equal ( 2 ) ;
431
431
} ) ;
432
432
433
433
it ( 'should cache after parsing for an ambiguous module' , function ( ) {
434
434
const source = './typescript-declare-module.ts' ;
435
- const parseSpy = sinon . spy ( ExportMap , 'parse' ) ;
435
+ const parseSpy = sinon . spy ( ExportMapBuilder , 'parse' ) ;
436
436
437
- expect ( ExportMap . get ( source , context ) ) . to . be . null ;
437
+ expect ( ExportMapBuilder . get ( source , context ) ) . to . be . null ;
438
438
439
- ExportMap . get ( source , context ) ;
439
+ ExportMapBuilder . get ( source , context ) ;
440
440
441
441
expect ( parseSpy . callCount ) . to . equal ( 1 ) ;
442
442
0 commit comments