@@ -2,73 +2,62 @@ import path from 'path';
22import { expect } from 'chai' ;
33import * as buildTree from './build-tree' ;
44
5- const fixtures = `${ __dirname } /../../fixtures` ;
5+ const fixtures = `${ __dirname } /../../../../../ fixtures` ;
66const precinctFixtures = path . join ( fixtures , 'precinct' ) ;
77const buildTreeFixtures = path . join ( fixtures , 'build-tree' ) ;
88
99describe ( 'buildTree' , ( ) => {
1010 describe ( 'getDependencyTree' , ( ) => {
11+ const filePaths : string [ ] = [ ] ;
12+ let visited : any ;
1113 const dependencyTreeParams = {
1214 baseDir : '.' ,
1315 workspacePath : __dirname ,
14- filePaths : [ ] ,
16+ filePaths,
1517 bindingPrefix : '@bit' ,
18+ visited,
1619 resolveModulesConfig : undefined
1720 } ;
1821 it ( 'when no files are passed should return an empty tree' , async ( ) => {
19- // @ts -ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
2022 const results = await buildTree . getDependencyTree ( dependencyTreeParams ) ;
2123 expect ( results ) . to . deep . equal ( { tree : { } } ) ;
2224 } ) ;
2325 it ( 'when unsupported files are passed should return them with no dependencies' , async ( ) => {
24- // @ts -ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
2526 dependencyTreeParams . filePaths = [ `${ fixtures } /unsupported-file.pdf` ] ;
26- // @ts -ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
2727 const results = await buildTree . getDependencyTree ( dependencyTreeParams ) ;
2828 expect ( results . tree ) . to . deep . equal ( { 'fixtures/unsupported-file.pdf' : { } } ) ;
2929 } ) ;
3030 it ( 'when supported and unsupported files are passed should return them all' , async ( ) => {
31- // @ts -ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
32- // @ts -ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
3331 dependencyTreeParams . filePaths = [ `${ fixtures } /unsupported-file.pdf` , `${ precinctFixtures } /es6.js` ] ;
34- // @ts -ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
3532 const results = await buildTree . getDependencyTree ( dependencyTreeParams ) ;
3633 expect ( results . tree ) . to . have . property ( 'fixtures/unsupported-file.pdf' ) ;
3734 expect ( results . tree ) . to . have . property ( 'fixtures/precinct/es6.js' ) ;
3835 } ) ;
3936 it ( 'when a js file has parsing error it should add the file to the tree with the error instance' , async ( ) => {
40- // @ts -ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
4137 dependencyTreeParams . filePaths = [ `${ precinctFixtures } /unparseable.js` ] ;
42- // @ts -ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
4338 const results = await buildTree . getDependencyTree ( dependencyTreeParams ) ;
4439 const unParsedFile = 'fixtures/precinct/unparseable.js' ;
4540 expect ( results . tree ) . to . have . property ( unParsedFile ) ;
4641 expect ( results . tree [ unParsedFile ] ) . to . have . property ( 'error' ) ;
4742 expect ( results . tree [ unParsedFile ] . error ) . to . be . instanceof ( Error ) ;
4843 } ) ;
4944 it ( 'when a js file has parsing error and it retrieved from the cache it should add the file to the tree with the error instance' , async ( ) => {
50- // @ts -ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
5145 dependencyTreeParams . filePaths = [ `${ precinctFixtures } /unparseable.js` ] ;
52- // @ts -ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
5346 dependencyTreeParams . visited = { } ;
54- // @ts -ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
5547 const results = await buildTree . getDependencyTree ( dependencyTreeParams ) ;
5648 const unParsedFile = 'fixtures/precinct/unparseable.js' ;
5749 expect ( results . tree ) . to . have . property ( unParsedFile ) ;
5850 expect ( results . tree [ unParsedFile ] ) . to . have . property ( 'error' ) ;
5951 expect ( results . tree [ unParsedFile ] . error ) . to . be . instanceof ( Error ) ;
6052
6153 // second time, this time it fetches from the cache (visited object)
62- // @ts -ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
6354 const resultsCached = await buildTree . getDependencyTree ( dependencyTreeParams ) ;
6455 expect ( resultsCached . tree ) . to . have . property ( unParsedFile ) ;
6556 expect ( resultsCached . tree [ unParsedFile ] ) . to . have . property ( 'error' ) ;
6657 expect ( resultsCached . tree [ unParsedFile ] . error ) . to . be . instanceof ( Error ) ;
6758 } ) ;
6859 it . skip ( 'when a css file has parsing error it should add the file to the tree with the error instance' , async ( ) => {
69- // @ts -ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
7060 dependencyTreeParams . filePaths = [ `${ buildTreeFixtures } /unparsed.css` ] ;
71- // @ts -ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
7261 const results = await buildTree . getDependencyTree ( dependencyTreeParams ) ;
7362 const unParsedFile = 'fixtures/build-tree/unparsed.css' ;
7463 expect ( results . tree ) . to . have . property ( unParsedFile ) ;
@@ -78,10 +67,7 @@ describe('buildTree', () => {
7867 describe ( 'when a dependency of dependency has parsing error' , ( ) => {
7968 let results ;
8069 before ( async ( ) => {
81- // @ts -ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
82- // @ts -ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
8370 dependencyTreeParams . filePaths = [ `${ buildTreeFixtures } /a.js` , `${ buildTreeFixtures } /b.js` ] ;
84- // @ts -ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
8571 results = await buildTree . getDependencyTree ( dependencyTreeParams ) ;
8672 } ) ;
8773 it ( 'should add all the files to the tree' , async ( ) => {
@@ -102,9 +88,7 @@ describe('buildTree', () => {
10288 let results ;
10389 const missingDepsFile = 'fixtures/missing-deps.js' ;
10490 before ( async ( ) => {
105- // @ts -ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
10691 dependencyTreeParams . filePaths = [ `${ fixtures } /missing-deps.js` ] ;
107- // @ts -ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
10892 results = await buildTree . getDependencyTree ( dependencyTreeParams ) ;
10993 expect ( results . tree ) . to . have . property ( missingDepsFile ) ;
11094 expect ( results . tree [ missingDepsFile ] ) . to . have . property ( 'missing' ) ;
@@ -122,9 +106,7 @@ describe('buildTree', () => {
122106 describe ( 'when a file imports from itself' , ( ) => {
123107 let results ;
124108 before ( async ( ) => {
125- // @ts -ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
126109 dependencyTreeParams . filePaths = [ `${ buildTreeFixtures } /tree-shaking-cycle/self-cycle.js` ] ;
127- // @ts -ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
128110 results = await buildTree . getDependencyTree ( dependencyTreeParams ) ;
129111 } ) ;
130112 it ( 'should not throw an error and should remove itself from the dependencies files' , ( ) => {
@@ -135,9 +117,7 @@ describe('buildTree', () => {
135117 describe ( 'cycle with multiple files' , ( ) => {
136118 let results ;
137119 before ( async ( ) => {
138- // @ts -ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
139120 dependencyTreeParams . filePaths = [ `${ buildTreeFixtures } /tree-shaking-cycle/foo.js` ] ;
140- // @ts -ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
141121 results = await buildTree . getDependencyTree ( dependencyTreeParams ) ;
142122 } ) ;
143123 it ( 'should not recognize the cycle dependencies as link files' , ( ) => {
@@ -155,9 +135,7 @@ describe('buildTree', () => {
155135 describe ( 'fileA imports varX from fileB, fileB imports varX from fileC but not export it' , ( ) => {
156136 let results ;
157137 before ( async ( ) => {
158- // @ts -ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
159138 dependencyTreeParams . filePaths = [ `${ buildTreeFixtures } /not-link-file/file-a.js` ] ;
160- // @ts -ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
161139 results = await buildTree . getDependencyTree ( dependencyTreeParams ) ;
162140 } ) ;
163141 it ( 'should not mark fileB as a link file' , ( ) => {
0 commit comments