@@ -24,24 +24,21 @@ const reporterSpy = spy.interface({
24
24
measurements ?: { [ p : string ] : number }
25
25
) : void { } ,
26
26
} ) ;
27
- describe ( "upgrade show what's new log " , ( ) => {
27
+ describe ( "upgrade show changelog " , ( ) => {
28
28
const sandbox = sinon . createSandbox ( ) ;
29
29
let context : vscode . ExtensionContext ;
30
+ let telemetryStub : sinon . SinonStub ;
30
31
const mockGlobalState : vscode . Memento = {
31
32
keys : gloablStateKeys ,
32
33
get : globalStateGet ,
33
34
update : globalStateUpdate ,
34
35
} ;
35
- before ( ( ) => {
36
- chai . util . addProperty ( ExtTelemetry , "reporter" , ( ) => reporterSpy ) ;
37
- } ) ;
38
36
beforeEach ( ( ) => {
39
37
context = {
40
38
subscriptions : [ ] ,
41
39
globalState : mockGlobalState ,
42
40
} as unknown as vscode . ExtensionContext ;
43
41
sandbox . stub ( versionUtil , "getExtensionId" ) . returns ( "" ) ;
44
- sandbox . stub ( vscode . window , "showInformationMessage" ) . resolves ( ) ;
45
42
sandbox . stub ( vscode . extensions , "getExtension" ) . returns ( {
46
43
packageJSON : { version : "5.0.0" } ,
47
44
id : "" ,
@@ -54,26 +51,43 @@ describe("upgrade show what's new log", () => {
54
51
return Promise . resolve ( ) ;
55
52
} ,
56
53
} ) ;
54
+ telemetryStub = sandbox . stub ( ExtTelemetry , "sendTelemetryEvent" ) ;
57
55
} ) ;
58
56
afterEach ( ( ) => {
59
57
sandbox . restore ( ) ;
60
58
} ) ;
61
- it ( "show what's new notification happy path" , async ( ) => {
59
+ it ( "show changelog notification happy path" , async ( ) => {
62
60
const contextSpy = sandbox . spy ( context . globalState , "update" ) ;
63
61
sandbox . stub ( context . globalState , "get" ) . returns ( "4.99.0" ) ;
62
+ let title = "" ;
63
+ sandbox
64
+ . stub ( vscode . window , "showInformationMessage" )
65
+ . callsFake ( ( _message : string , option : any , ...items : vscode . MessageItem [ ] ) => {
66
+ title = option . title ;
67
+ return Promise . resolve ( option ) ;
68
+ } ) ;
64
69
const instance = new ExtensionUpgrade ( context ) ;
65
70
await instance . showChangeLog ( ) ;
71
+ chai . assert ( title === "Changelog" ) ;
66
72
chai . assert ( contextSpy . callCount == 2 ) ;
67
- chai
68
- . expect ( reporterSpy . sendTelemetryEvent )
69
- . to . have . been . called . with ( "show-what-is-new-notification" ) ;
73
+ chai . assert ( telemetryStub . calledWith ( "show-what-is-new-notification" ) ) ;
70
74
} ) ;
71
- it ( "should not show whate's new log when version is not changed" , async ( ) => {
75
+ it ( "should not show changelog if button is not clicked" , async ( ) => {
76
+ const contextSpy = sandbox . spy ( context . globalState , "update" ) ;
77
+ sandbox . stub ( context . globalState , "get" ) . returns ( "4.99.0" ) ;
78
+ sandbox . stub ( vscode . window , "showInformationMessage" ) . resolves ( undefined ) ;
79
+ const instance = new ExtensionUpgrade ( context ) ;
80
+ await instance . showChangeLog ( ) ;
81
+ chai . assert ( contextSpy . callCount == 2 ) ;
82
+ chai . assert ( telemetryStub . calledOnce ) ;
83
+ } ) ;
84
+ it ( "should not show changelog when version is not changed" , async ( ) => {
72
85
const contextSpy = sandbox . spy ( context . globalState , "update" ) ;
73
86
sandbox . stub ( context . globalState , "get" ) . returns ( "5.0.0" ) ;
87
+ sandbox . stub ( vscode . window , "showInformationMessage" ) . resolves ( ) ;
74
88
const instance = new ExtensionUpgrade ( context ) ;
75
89
await instance . showChangeLog ( ) ;
76
90
sinon . assert . notCalled ( contextSpy ) ;
77
- chai . expect ( reporterSpy . sendTelemetryEvent ) . to . not . have . been . called ;
91
+ chai . assert ( telemetryStub . notCalled ) ;
78
92
} ) ;
79
93
} ) ;
0 commit comments