11import * as plugin from '../../../lib' ;
22import * as path from 'path' ;
33import { readFixtureJSON } from '../../helpers/read' ;
4- import * as subProcess from '../../../lib/sub-process' ;
54import { sortDependencyGraphDeps } from '../../helpers/sort' ;
65import { DepGraphData } from '@snyk/dep-graph' ;
76import { legacyPlugin } from '@snyk/cli-interface' ;
7+ import { MultiProjectResult } from '@snyk/cli-interface/legacy/plugin' ;
88
99const testsPath = path . join ( __dirname , '../..' ) ;
1010const fixturesPath = path . join ( testsPath , 'fixtures' ) ;
@@ -36,7 +36,7 @@ describe('Dverbose reuturning all considered versions for dependencies tests', (
3636 const result = res . scannedProjects [ 0 ] . depGraph . toJSON ( ) ;
3737 const expectedGraphSorted = sortDependencyGraphDeps ( expectedJSON ) ;
3838 const actualGraphSorted = sortDependencyGraphDeps ( result ) ;
39- expect ( expectedGraphSorted ) . toEqual ( actualGraphSorted ) ;
39+ expect ( actualGraphSorted ) . toEqual ( expectedGraphSorted ) ;
4040 expect (
4141 res . plugin . meta . versionBuildInfo . metaBuildVersion . mavenPluginVersion ,
4242 ) . toEqual ( '3.6.1' ) ;
@@ -63,37 +63,43 @@ describe('Dverbose reuturning all considered versions for dependencies tests', (
6363 ) ;
6464 const expectedGraphSorted = sortDependencyGraphDeps ( expectedJSON ) ;
6565 const actualGraphSorted = sortDependencyGraphDeps ( result ) ;
66- expect ( expectedGraphSorted ) . toEqual ( actualGraphSorted ) ;
66+ expect ( actualGraphSorted ) . toEqual ( expectedGraphSorted ) ;
6767 } ,
6868 TESTS_TIMEOUT ,
6969 ) ;
7070
7171 test (
7272 'inspect on dverbose-dependency-management pom using -Dverbose and --dev deps' ,
7373 async ( ) => {
74- const res : Record < string , any > = await plugin . inspect (
74+ const res = ( await plugin . inspect (
7575 '.' ,
7676 path . join ( testManagedProjectPath , 'pom.xml' ) ,
7777 {
7878 dev : true ,
7979 args : [ '-Dverbose' ] ,
8080 mavenVerboseIncludeAllVersions : true ,
8181 } ,
82- ) ;
83- const result = res . scannedProjects [ 0 ] . depGraph . toJSON ( ) ;
82+ ) ) as MultiProjectResult ;
83+ const result = res . scannedProjects [ 0 ] . depGraph ? .toJSON ( ) as DepGraphData ;
8484
85- // if running windows with an older version of maven 3.3.9.2 - one of the deps will be omitted
86- const mavenVersion = await subProcess . execute ( 'mvn' , [ '--version' ] , { } ) ;
87- let expectedJSON = await readFixtureJSON (
85+ const javaVersion =
86+ res . plugin . meta ?. versionBuildInfo ?. metaBuildVersion . javaVersion || '' ;
87+ const isJava8 =
88+ javaVersion . includes ( '1.8.' ) || javaVersion . includes ( 'version: 8' ) ;
89+
90+ // Java 8 has a missing dependency
91+ const expectedFileName = isJava8
92+ ? 'expected-dverbose-dep-graph-dev-java8.json'
93+ : 'expected-dverbose-dep-graph-dev.json' ;
94+
95+ const expectedJSON = await readFixtureJSON (
8896 'dverbose-dependency-management' ,
89- mavenVersion . includes ( '3.3.9' ) && mavenVersion . includes ( 'C:' )
90- ? 'expected-dverbose-dep-graph-dev-old-maven.json'
91- : 'expected-dverbose-dep-graph-dev.json' ,
97+ expectedFileName ,
9298 ) ;
9399
94100 const expectedGraphSorted = sortDependencyGraphDeps ( expectedJSON ) ;
95101 const actualGraphSorted = sortDependencyGraphDeps ( result ) ;
96- expect ( expectedGraphSorted ) . toEqual ( actualGraphSorted ) ;
102+ expect ( actualGraphSorted ) . toEqual ( expectedGraphSorted ) ;
97103 } ,
98104 TESTS_TIMEOUT ,
99105 ) ;
@@ -125,7 +131,7 @@ describe('Dverbose reuturning all considered versions for dependencies tests', (
125131 expectedJSON . scannedProjects [ i ] . depGraph ,
126132 ) ;
127133 const actualGraphSorted = sortDependencyGraphDeps ( depGraph ) ;
128- expect ( expectedGraphSorted ) . toEqual ( actualGraphSorted ) ;
134+ expect ( actualGraphSorted ) . toEqual ( expectedGraphSorted ) ;
129135 }
130136 } ,
131137 TESTS_TIMEOUT ,
@@ -150,7 +156,7 @@ describe('Dverbose reuturning all considered versions for dependencies tests', (
150156 const result = res . scannedProjects [ 0 ] . depGraph . toJSON ( ) ;
151157 const expectedGraphSorted = sortDependencyGraphDeps ( expectedJSON ) ;
152158 const actualGraphSorted = sortDependencyGraphDeps ( result ) ;
153- expect ( expectedGraphSorted ) . toEqual ( actualGraphSorted ) ;
159+ expect ( actualGraphSorted ) . toEqual ( expectedGraphSorted ) ;
154160 } ,
155161 TESTS_TIMEOUT ,
156162 ) ;
@@ -176,7 +182,7 @@ describe('Dverbose reuturning all considered versions for dependencies tests', (
176182 const result = res . scannedProjects [ 0 ] . depGraph . toJSON ( ) ;
177183 const expectedGraphSorted = sortDependencyGraphDeps ( expectedJSON ) ;
178184 const actualGraphSorted = sortDependencyGraphDeps ( result ) ;
179- expect ( expectedGraphSorted ) . toEqual ( actualGraphSorted ) ;
185+ expect ( actualGraphSorted ) . toEqual ( expectedGraphSorted ) ;
180186 } ,
181187 TESTS_TIMEOUT ,
182188 ) ;
@@ -202,7 +208,7 @@ describe('Dverbose reuturning all considered versions for dependencies tests', (
202208 const result = res . scannedProjects [ 0 ] . depGraph . toJSON ( ) ;
203209 const expectedGraphSorted = sortDependencyGraphDeps ( expectedJSON ) ;
204210 const actualGraphSorted = sortDependencyGraphDeps ( result ) ;
205- expect ( expectedGraphSorted ) . toEqual ( actualGraphSorted ) ;
211+ expect ( actualGraphSorted ) . toEqual ( expectedGraphSorted ) ;
206212 } ,
207213 TESTS_TIMEOUT ,
208214 ) ;
@@ -230,7 +236,7 @@ describe('Dverbose reuturning all considered versions for dependencies tests', (
230236 }
231237 const expectedGraphSorted = sortDependencyGraphDeps ( expectedJSON ) ;
232238 const actualGraphSorted = sortDependencyGraphDeps ( res ) ;
233- expect ( expectedGraphSorted ) . toEqual ( actualGraphSorted ) ;
239+ expect ( actualGraphSorted ) . toEqual ( expectedGraphSorted ) ;
234240 } ,
235241 TESTS_TIMEOUT ,
236242 ) ;
@@ -258,7 +264,7 @@ describe('Dverbose reuturning all considered versions for dependencies tests', (
258264 }
259265 const expectedGraphSorted = sortDependencyGraphDeps ( expectedJSON ) ;
260266 const actualGraphSorted = sortDependencyGraphDeps ( res ) ;
261- expect ( expectedGraphSorted ) . toEqual ( actualGraphSorted ) ;
267+ expect ( actualGraphSorted ) . toEqual ( expectedGraphSorted ) ;
262268 } ,
263269 TESTS_TIMEOUT ,
264270 ) ;
0 commit comments