1- import { beforeAll , describe , expect , test } from 'vitest' ;
2-
3- import { Targets } from '../src/targets'
4- import path from 'path' ;
5- import { setupFixture } from './fixtures/projects' ;
6- import { ReadFileSystem } from '../src/readFileSystem' ;
7-
8- // This issue was occuring when you had two files with the same name, but different extensions.
9-
10- describe ( `include_mismatch_fix tests` , ( ) => {
11- const project = setupFixture ( `include_mismatch_fix` ) ;
12-
13- const fs = new ReadFileSystem ( ) ;
14- const targets = new Targets ( project . cwd , fs ) ;
15- targets . setSuggestions ( { renames : true , includes : true } )
16-
17- beforeAll ( async ( ) => {
18- project . setup ( ) ;
19- await targets . loadProject ( ) ;
20-
21- expect ( targets . getTargets ( ) . length ) . toBeGreaterThan ( 0 ) ;
22- targets . resolveBinder ( ) ;
23- } ) ;
24-
25- test ( `Ensure rename is against correct file` , async ( ) => {
26- const articlePf = targets . getTarget ( { systemName : `ARTICLE` , type : `FILE` } ) ;
27- expect ( articlePf ) . toBeDefined ( ) ;
28-
29- const articlePfLogs = targets . logger . getLogsFor ( articlePf . relativePath ) ;
30- expect ( articlePfLogs . length ) . toBe ( 1 ) ;
31- expect ( articlePfLogs [ 0 ] . message ) . toBe ( `no object found for reference 'SAMREF'` ) ;
32- expect ( articlePfLogs [ 0 ] . type ) . toBe ( `warning` ) ;
33-
34- const articleIncludeLogs = targets . logger . getLogsFor ( path . join ( `QPROTOSRC` , `ARTICLE.RPGLE` ) ) ;
35- expect ( articleIncludeLogs . length ) . toBe ( 1 ) ;
36- expect ( articleIncludeLogs [ 0 ] . message ) . toBe ( `Rename suggestion` ) ;
37- expect ( articleIncludeLogs [ 0 ] . type ) . toBe ( `rename` ) ;
38- expect ( articleIncludeLogs [ 0 ] . change ) . toMatchObject ( {
39- rename : {
40- path : path . join ( project . cwd , `QPROTOSRC` , `ARTICLE.RPGLE` ) ,
41- newName : 'ARTICLE.rpgleinc'
42- }
43- } )
44- } ) ;
1+ import { beforeAll , describe , expect , test } from 'vitest' ;
2+
3+ import { Targets } from '../src/targets'
4+ import path from 'path' ;
5+ import { setupFixture } from './fixtures/projects' ;
6+ import { ReadFileSystem } from '../src/readFileSystem' ;
7+
8+ // This issue was occuring when you had two files with the same name, but different extensions.
9+
10+ describe ( `include_mismatch_fix tests` , ( ) => {
11+ const project = setupFixture ( `include_mismatch_fix` ) ;
12+
13+ const fs = new ReadFileSystem ( ) ;
14+ const targets = new Targets ( project . cwd , fs ) ;
15+ targets . setSuggestions ( { renames : true , includes : true } )
16+
17+ beforeAll ( async ( ) => {
18+ project . setup ( ) ;
19+ await targets . loadProject ( ) ;
20+
21+ expect ( targets . getTargets ( ) . length ) . toBeGreaterThan ( 0 ) ;
22+ targets . resolveBinder ( ) ;
23+ } ) ;
24+
25+ test ( `Ensure rename is against correct file` , async ( ) => {
26+ const articlePf = targets . getTarget ( { systemName : `ARTICLE` , type : `FILE` } ) ;
27+ expect ( articlePf ) . toBeDefined ( ) ; articlePf . relativePath
28+
29+ const articlePfLogs = targets . logger . getLogsFor ( path . join ( `QDDSSRC` , `ARTICLE.PF` ) ) ;
30+ expect ( articlePfLogs . length ) . toBe ( 1 ) ;
31+ expect ( articlePfLogs [ 0 ] . message ) . toBe ( `no object found for reference 'SAMREF'` ) ;
32+ expect ( articlePfLogs [ 0 ] . type ) . toBe ( `warning` ) ;
33+
34+ const articleIncludeLogs = targets . logger . getLogsFor ( path . join ( `QPROTOSRC` , `ARTICLE.RPGLE` ) ) ;
35+ expect ( articleIncludeLogs . length ) . toBe ( 1 ) ;
36+ expect ( articleIncludeLogs [ 0 ] . message ) . toBe ( `Rename suggestion` ) ;
37+ expect ( articleIncludeLogs [ 0 ] . type ) . toBe ( `rename` ) ;
38+ expect ( articleIncludeLogs [ 0 ] . change ) . toMatchObject ( {
39+ rename : {
40+ path : path . join ( project . cwd , `QPROTOSRC` , `ARTICLE.RPGLE` ) ,
41+ newName : 'ARTICLE.rpgleinc'
42+ }
43+ } )
44+ } ) ;
4545} ) ;
0 commit comments