11import * as simple from "simple-mock" ;
22import assert = require( "assert" ) ;
3- import { ExtensionContext , workspace } from "vscode" ;
3+ import { ExtensionContext , workspace , window } from "vscode" ;
44import { getConfiguration } from "../../../lib/ggshield-configuration-utils" ;
55import * as ggshieldResolverUtils from "../../../lib/ggshield-resolver-utils" ;
66
77suite ( "getConfiguration" , ( ) => {
88 let getConfigurationMock : simple . Stub < Function > ;
9- let getGGShieldAbsolutePathMock : simple . Stub < ( platform : NodeJS . Platform , arch : string , context : ExtensionContext ) => string > ;
9+ let getGGShieldAbsolutePathMock : simple . Stub <
10+ (
11+ platform : NodeJS . Platform ,
12+ arch : string ,
13+ context : ExtensionContext
14+ ) => string
15+ > ;
1016
1117 setup ( ( ) => {
1218 // Mock workspace.getConfiguration
1319 getConfigurationMock = simple . mock ( workspace , "getConfiguration" ) ;
1420 // Mock getGGShieldAbsolutePath
15- getGGShieldAbsolutePathMock = simple . mock ( ggshieldResolverUtils , "getGGShieldAbsolutePath" ) . returnWith (
16- ( ) => "/mock/path/to/ggshield"
17- ) ;
21+ getGGShieldAbsolutePathMock = simple
22+ . mock ( ggshieldResolverUtils , "getGGShieldAbsolutePath" )
23+ . returnWith ( ( ) => "/mock/path/to/ggshield" ) ;
1824 } ) ;
1925
2026 teardown ( ( ) => {
@@ -23,6 +29,7 @@ suite("getConfiguration", () => {
2329
2430 test ( "Vscode settings are correctly read" , ( ) => {
2531 const context = { } as ExtensionContext ;
32+ const outputChannel = window . createOutputChannel ( "GitGuardian" ) ;
2633 simple . mock ( context , "asAbsolutePath" ) . returnWith ( "" ) ;
2734
2835 getConfigurationMock . returnWith ( {
@@ -35,10 +42,13 @@ suite("getConfiguration", () => {
3542 }
3643 } ,
3744 } ) ;
38- const configuration = getConfiguration ( context ) ;
45+ const configuration = getConfiguration ( context , outputChannel ) ;
3946
4047 // Assert both workspace.getConfiguration and GGShieldConfiguration constructor were called
41- assert ( getConfigurationMock . called , "getConfiguration should be called once" ) ;
48+ assert (
49+ getConfigurationMock . called ,
50+ "getConfiguration should be called once"
51+ ) ;
4252
4353 // Assert that the configuration has the expected values
4454 assert . strictEqual ( configuration . apiUrl , "https://custom-url.com" ) ;
0 commit comments