11import * as simple from "simple-mock" ;
22import assert = require( "assert" ) ;
33import { ExtensionContext , workspace } from "vscode" ;
4- import * as GGShieldConfiguration from "../../../lib/ggshield-configuration" ;
54import { getConfiguration } from "../../../lib/ggshield-configuration-utils" ;
65
76suite ( "getConfiguration" , ( ) => {
87 let getConfigurationMock : simple . Stub < Function > ;
9- let constructorMock : simple . Stub < Function > ;
10- let context : Partial < ExtensionContext > ;
118
129 setup ( ( ) => {
1310 // Mock workspace.getConfiguration
1411 getConfigurationMock = simple . mock ( workspace , "getConfiguration" ) ;
15-
16- // Mock the GGShieldConfiguration constructor globally
17- constructorMock = simple . mock (
18- GGShieldConfiguration ,
19- "GGShieldConfiguration"
20- ) ;
21- context = { } as ExtensionContext ;
2212 } ) ;
2313
2414 teardown ( ( ) => {
@@ -42,25 +32,18 @@ suite("getConfiguration", () => {
4232 }
4333 } ,
4434 } ) ;
45- constructorMock . returnWith ( { } ) ;
46-
47- getConfiguration ( context as ExtensionContext ) ;
35+ const configuration = getConfiguration ( { } as ExtensionContext ) ;
4836
4937 // Assert both workspace.getConfiguration and GGShieldConfiguration constructor were called
5038 assert (
5139 getConfigurationMock . called ,
5240 "getConfiguration should be called once"
5341 ) ;
54- assert (
55- constructorMock . called ,
56- "GGShieldConfiguration constructor should be called once"
57- ) ;
5842
59- // Check the arguments passed to GGShieldConfiguration constructor
60- const ggshieldConfigurationArgs = constructorMock . lastCall . args ;
61- assert . strictEqual ( ggshieldConfigurationArgs [ 0 ] , "path/to/ggshield" ) ;
62- assert . strictEqual ( ggshieldConfigurationArgs [ 1 ] , "https://custom-url.com" ) ;
63- assert . strictEqual ( ggshieldConfigurationArgs [ 2 ] , "test-api-key" ) ;
64- assert . strictEqual ( ggshieldConfigurationArgs [ 3 ] , true ) ;
43+ // Assert that the configuration has the expected values
44+ assert . strictEqual ( configuration . ggshieldPath , "path/to/ggshield" ) ;
45+ assert . strictEqual ( configuration . apiUrl , "https://custom-url.com" ) ;
46+ assert . strictEqual ( configuration . apiKey , "test-api-key" ) ;
47+ assert . strictEqual ( configuration . allowSelfSigned , true ) ;
6548 } ) ;
6649} ) ;
0 commit comments