11import sinon from 'sinon' ;
22import { expect } from 'chai' ;
33import StronglyConnectedComponentsBuilder from '../../src/scc' ;
4+ import ExportMapBuilder from '../../src/exportMap/builder' ;
45
56function exportMapFixtureBuilder ( path , imports ) {
67 return {
@@ -10,9 +11,7 @@ function exportMapFixtureBuilder(path, imports) {
1011}
1112
1213describe ( 'Strongly Connected Components Builder' , ( ) => {
13- const fakeExportMapBuilder = { for : sinon . spy ( ) } ;
14- before ( ( ) => StronglyConnectedComponentsBuilder . injectExportMapBuilder ( fakeExportMapBuilder ) ) ;
15- after ( ( ) => StronglyConnectedComponentsBuilder . resetExportMapBuilder ( ) ) ;
14+ afterEach ( ( ) => ExportMapBuilder . for . restore ( ) ) ;
1615 afterEach ( ( ) => StronglyConnectedComponentsBuilder . clearCache ( ) ) ;
1716
1817 describe ( 'When getting an SCC' , ( ) => {
@@ -26,7 +25,7 @@ describe('Strongly Connected Components Builder', () => {
2625 describe ( 'Given two files' , ( ) => {
2726 describe ( 'When they don\'t cycle' , ( ) => {
2827 it ( 'Should return foreign SCCs' , ( ) => {
29- fakeExportMapBuilder . for = sinon . stub ( ) . returns (
28+ sinon . stub ( ExportMapBuilder , 'for' ) . returns (
3029 exportMapFixtureBuilder ( 'foo.js' , [ exportMapFixtureBuilder ( 'bar.js' , [ ] ) ] ) ,
3130 ) ;
3231 const actual = StronglyConnectedComponentsBuilder . for ( source , context ) ;
@@ -36,7 +35,7 @@ describe('Strongly Connected Components Builder', () => {
3635
3736 describe ( 'When they do cycle' , ( ) => {
3837 it ( 'Should return same SCC' , ( ) => {
39- fakeExportMapBuilder . for = sinon . stub ( ) . returns (
38+ sinon . stub ( ExportMapBuilder , 'for' ) . returns (
4039 exportMapFixtureBuilder ( 'foo.js' , [
4140 exportMapFixtureBuilder ( 'bar.js' , [
4241 exportMapFixtureBuilder ( 'foo.js' , [ ] ) ,
@@ -53,7 +52,7 @@ describe('Strongly Connected Components Builder', () => {
5352 describe ( 'When they form a line' , ( ) => {
5453 describe ( 'When A -> B -> C' , ( ) => {
5554 it ( 'Should return foreign SCCs' , ( ) => {
56- fakeExportMapBuilder . for = sinon . stub ( ) . returns (
55+ sinon . stub ( ExportMapBuilder , 'for' ) . returns (
5756 exportMapFixtureBuilder ( 'foo.js' , [
5857 exportMapFixtureBuilder ( 'bar.js' , [
5958 exportMapFixtureBuilder ( 'buzz.js' , [ ] ) ,
@@ -67,7 +66,7 @@ describe('Strongly Connected Components Builder', () => {
6766
6867 describe ( 'When A -> B <-> C' , ( ) => {
6968 it ( 'Should return 2 SCCs, A on its own' , ( ) => {
70- fakeExportMapBuilder . for = sinon . stub ( ) . returns (
69+ sinon . stub ( ExportMapBuilder , 'for' ) . returns (
7170 exportMapFixtureBuilder ( 'foo.js' , [
7271 exportMapFixtureBuilder ( 'bar.js' , [
7372 exportMapFixtureBuilder ( 'buzz.js' , [
@@ -83,7 +82,7 @@ describe('Strongly Connected Components Builder', () => {
8382
8483 describe ( 'When A <-> B -> C' , ( ) => {
8584 it ( 'Should return 2 SCCs, C on its own' , ( ) => {
86- fakeExportMapBuilder . for = sinon . stub ( ) . returns (
85+ sinon . stub ( ExportMapBuilder , 'for' ) . returns (
8786 exportMapFixtureBuilder ( 'foo.js' , [
8887 exportMapFixtureBuilder ( 'bar.js' , [
8988 exportMapFixtureBuilder ( 'buzz.js' , [ ] ) ,
@@ -98,7 +97,7 @@ describe('Strongly Connected Components Builder', () => {
9897
9998 describe ( 'When A <-> B <-> C' , ( ) => {
10099 it ( 'Should return same SCC' , ( ) => {
101- fakeExportMapBuilder . for = sinon . stub ( ) . returns (
100+ sinon . stub ( ExportMapBuilder , 'for' ) . returns (
102101 exportMapFixtureBuilder ( 'foo.js' , [
103102 exportMapFixtureBuilder ( 'bar.js' , [
104103 exportMapFixtureBuilder ( 'foo.js' , [ ] ) ,
@@ -116,7 +115,7 @@ describe('Strongly Connected Components Builder', () => {
116115
117116 describe ( 'When they form a loop' , ( ) => {
118117 it ( 'Should return same SCC' , ( ) => {
119- fakeExportMapBuilder . for = sinon . stub ( ) . returns (
118+ sinon . stub ( ExportMapBuilder , 'for' ) . returns (
120119 exportMapFixtureBuilder ( 'foo.js' , [
121120 exportMapFixtureBuilder ( 'bar.js' , [
122121 exportMapFixtureBuilder ( 'buzz.js' , [
@@ -132,7 +131,7 @@ describe('Strongly Connected Components Builder', () => {
132131
133132 describe ( 'When they form a Y' , ( ) => {
134133 it ( 'Should return 3 distinct SCCs' , ( ) => {
135- fakeExportMapBuilder . for = sinon . stub ( ) . returns (
134+ sinon . stub ( ExportMapBuilder , 'for' ) . returns (
136135 exportMapFixtureBuilder ( 'foo.js' , [
137136 exportMapFixtureBuilder ( 'bar.js' , [ ] ) ,
138137 exportMapFixtureBuilder ( 'buzz.js' , [ ] ) ,
@@ -145,7 +144,7 @@ describe('Strongly Connected Components Builder', () => {
145144
146145 describe ( 'When they form a Mercedes' , ( ) => {
147146 it ( 'Should return 1 SCC' , ( ) => {
148- fakeExportMapBuilder . for = sinon . stub ( ) . returns (
147+ sinon . stub ( ExportMapBuilder , 'for' ) . returns (
149148 exportMapFixtureBuilder ( 'foo.js' , [
150149 exportMapFixtureBuilder ( 'bar.js' , [
151150 exportMapFixtureBuilder ( 'foo.js' , [ ] ) ,
0 commit comments