@@ -2,8 +2,8 @@ import { vi,test, describe, expect } from 'vitest';
22import  {  HtmlOutput  }  from  '../src/reporters/Output' ; 
33import  {  SmellsBuilder  }  from  '../src/smells-builder' ; 
44import  {  SmellsAggreagtor  }  from  '../src/reporters/SmellsAgreggator' ; 
5- import  {  ExportOptions ,   SmellsList  }  from  '../src/reporters/types' ; 
6- import  {  Smell ,  SmellType ,  SupportedLanguages  }  from  '../src/types' ; 
5+ import  {  ExportOptions  }  from  '../src/reporters/types' ; 
6+ import  {  Smell ,  SmellsList ,   SmellType ,  SupportedLanguages ,   TestCase  }  from  '../src/types' ; 
77
88vi . mock ( '../src/reporters/Output' ) ; 
99
@@ -37,7 +37,7 @@ describe('smells aggregator', () => {
3737
3838    const  write  =  vi . mocked ( HtmlOutput . prototype . writeTo  =  vi . fn ( ) ) ; 
3939
40-     const  reporter  =  new  SmellsAggreagtor ( smellsFound ,  exportsOptions ) ; 
40+     const  reporter  =  new  SmellsAggreagtor ( [ ] ,   smellsFound ,  exportsOptions ) ; 
4141
4242    await  reporter . build ( ) ; 
4343
@@ -51,20 +51,20 @@ describe('smells aggregator', () => {
5151
5252    const  write  =  vi . mocked ( HtmlOutput . prototype . writeTo  =  vi . fn ( ) ) ; 
5353
54-     const  reporter  =  new  SmellsAggreagtor ( smellsFound ,  exportsOptions ) ; 
54+     const  reporter  =  new  SmellsAggreagtor ( [ ] ,   smellsFound ,  exportsOptions ) ; 
5555
5656    await  reporter . build ( ) ; 
5757
5858    expect ( write . mock . calls [ 0 ] [ 0 ] . data [ 0 ] . fileContent ) . toEqual ( 'console.log("Hello world")' ) ; 
5959  } ) ; 
6060
61-   test . skip ( 'should send total of test cases to the output' ,  async  ( )  =>  { 
61+   test ( 'should send total of test cases to the output' ,  async  ( )  =>  { 
6262    const  smellsFound : SmellsList [ ]  =  buildListWithSingleSmell ( [ createSingleSmell ( ) ] ) ; 
6363    const  exportsOptions : ExportOptions  =  {  to : '.'  } ; 
6464
6565    const  write  =  vi . mocked ( HtmlOutput . prototype . writeTo  =  vi . fn ( ) ) ; 
6666
67-     const  reporter  =  new  SmellsAggreagtor ( smellsFound ,  exportsOptions ) ; 
67+     const  reporter  =  new  SmellsAggreagtor ( [ ] ,   smellsFound ,  exportsOptions ) ; 
6868
6969    await  reporter . build ( ) ; 
7070
@@ -77,36 +77,47 @@ describe('smells aggregator', () => {
7777
7878    const  write  =  vi . mocked ( HtmlOutput . prototype . writeTo  =  vi . fn ( ) ) ; 
7979
80-     const  reporter  =  new  SmellsAggreagtor ( smellsFound ,  exportsOptions ) ; 
80+     const  reporter  =  new  SmellsAggreagtor ( [ ] ,   smellsFound ,  exportsOptions ) ; 
8181
8282    await  reporter . build ( ) ; 
8383
8484    expect ( write . mock . calls [ 0 ] [ 0 ] . data ) . toEqual ( smellsFound ) ; 
8585  } ) ; 
8686
8787  test ( 'compute smells for a single file' ,  async  ( )  =>  { 
88-     const  smell : Smell  =  { 
89-       type : SmellType . consoleStatement , 
90-       lineStart : 0 , 
91-       lineEnd : 1 , 
92-       startAt : 10 , 
93-       endsAt : 20 , 
94-       description : '' , 
95-       diagnostic : '' 
96-     } ; 
97- 
9888    const  smellsFound : SmellsList [ ]  =  buildListWithSingleSmell ( [ createSingleSmell ( ) ] ) ; 
9989    const  exportsOptions : ExportOptions  =  {  to : '.'  } ; 
10090
10191    const  write  =  vi . mocked ( HtmlOutput . prototype . writeTo  =  vi . fn ( ) ) ; 
10292
103-     const  reporter  =  new  SmellsAggreagtor ( smellsFound ,  exportsOptions ) ; 
93+     const  reporter  =  new  SmellsAggreagtor ( [ ] ,   smellsFound ,  exportsOptions ) ; 
10494
10595    await  reporter . build ( ) ; 
10696
10797    expect ( write . mock . calls [ 0 ] [ 0 ] . totalSmells ) . toEqual ( 1 ) ; 
10898  } ) ; 
10999
100+   test ( 'compute test cases for a single file' ,  async  ( )  =>  { 
101+     const  smellsFound : SmellsList [ ]  =  buildListWithSingleSmell ( [ createSingleSmell ( ) ] ) ; 
102+     const  testCases : TestCase [ ]  =  [ 
103+       { 
104+         lineStart : 0 , 
105+         lineEnd : 0 , 
106+         startAt : 0 , 
107+         endsAt : 0 
108+       } 
109+     ] ; 
110+     const  exportsOptions : ExportOptions  =  {  to : '.'  } ; 
111+ 
112+     const  write  =  vi . mocked ( HtmlOutput . prototype . writeTo  =  vi . fn ( ) ) ; 
113+ 
114+     const  reporter  =  new  SmellsAggreagtor ( testCases ,  smellsFound ,  exportsOptions ) ; 
115+ 
116+     await  reporter . build ( ) ; 
117+ 
118+     expect ( write . mock . calls [ 0 ] [ 0 ] . totalTestCases ) . toEqual ( 1 ) ; 
119+   } ) ; 
120+ 
110121  test ( 'two test file with 5 smells each, should have average of 5 smells per test file' ,  async  ( )  =>  { 
111122    const  smell : Smell  =  SmellsBuilder . console ( 0 ,  1 ,  10 ,  20 ) ; 
112123    const  smellsFound : SmellsList [ ]  =  [ 
@@ -127,7 +138,7 @@ describe('smells aggregator', () => {
127138
128139    const  write  =  vi . mocked ( HtmlOutput . prototype . writeTo  =  vi . fn ( ) ) ; 
129140
130-     const  reporter  =  new  SmellsAggreagtor ( smellsFound ,  exportsOptions ) ; 
141+     const  reporter  =  new  SmellsAggreagtor ( [ ] ,   smellsFound ,  exportsOptions ) ; 
131142
132143    await  reporter . build ( ) ; 
133144
@@ -154,7 +165,7 @@ describe('smells aggregator', () => {
154165
155166    const  write  =  vi . mocked ( HtmlOutput . prototype . writeTo  =  vi . fn ( ) ) ; 
156167
157-     const  reporter  =  new  SmellsAggreagtor ( smellsFound ,  exportsOptions ) ; 
168+     const  reporter  =  new  SmellsAggreagtor ( [ ] ,   smellsFound ,  exportsOptions ) ; 
158169
159170    await  reporter . build ( ) ; 
160171
0 commit comments