@@ -6,11 +6,10 @@ import { SinonStub, SinonStubbedInstance, SinonStubbedMember, createSandbox, cre
6
6
import * as assert from 'assert'
7
7
import * as vscode from 'vscode'
8
8
9
- import { ExtensionUserActivity } from '../../../shared/extensionUtilities'
9
+ import { ExtensionUserActivity } from '../../../shared/extensionUtilities'
10
10
import { DevEnvClient , DevEnvActivity } from '../../../shared/clients/devenvClient'
11
11
import { sleep } from '../../../shared/utilities/timeoutUtils'
12
12
13
-
14
13
describe ( 'DevEnvActivity' , function ( ) {
15
14
let triggerUserActivityEvent : ( obj : any ) => Promise < void >
16
15
let userActivityEvent : SinonStub < Parameters < vscode . Event < any > > , vscode . Disposable >
@@ -19,15 +18,12 @@ describe('DevEnvActivity', function () {
19
18
let devEnvActivity : DevEnvActivity
20
19
let sandbox : sinon . SinonSandbox
21
20
22
- before ( function ( ) {
21
+ before ( function ( ) {
23
22
sandbox = createSandbox ( )
24
23
} )
25
24
26
25
beforeEach ( async function ( ) {
27
- userActivityEvent = sandbox . stub (
28
- vscode . window ,
29
- 'onDidChangeActiveColorTheme'
30
- )
26
+ userActivityEvent = sandbox . stub ( vscode . window , 'onDidChangeActiveColorTheme' )
31
27
userActivityEvent . callsFake ( ( throttledEventFire : ( obj : any ) => void ) => {
32
28
triggerUserActivityEvent = async ( obj : any ) => {
33
29
throttledEventFire ( obj )
@@ -38,13 +34,16 @@ describe('DevEnvActivity', function () {
38
34
await sleep ( 100 )
39
35
}
40
36
return {
41
- dispose : sandbox . stub ( )
37
+ dispose : sandbox . stub ( ) ,
42
38
}
43
39
} )
44
-
40
+
45
41
devEnvClientStub = createStubInstance ( DevEnvClient )
46
42
47
- devEnvActivity = ( await DevEnvActivity . instanceIfActivityTrackingEnabled ( devEnvClientStub as unknown as DevEnvClient , new ExtensionUserActivity ( 0 , [ userActivityEvent ] ) ) ) !
43
+ devEnvActivity = ( await DevEnvActivity . instanceIfActivityTrackingEnabled (
44
+ devEnvClientStub as unknown as DevEnvClient ,
45
+ new ExtensionUserActivity ( 0 , [ userActivityEvent ] )
46
+ ) ) !
48
47
} )
49
48
50
49
afterEach ( function ( ) {
@@ -57,12 +56,15 @@ describe('DevEnvActivity', function () {
57
56
58
57
it ( 'does not allow instance to be created if activity API not working' , async function ( ) {
59
58
devEnvClientStub . getActivity . throws ( )
60
- const instance = ( await DevEnvActivity . instanceIfActivityTrackingEnabled ( devEnvClientStub as unknown as DevEnvClient , new ExtensionUserActivity ( 0 , [ userActivityEvent ] ) ) )
59
+ const instance = await DevEnvActivity . instanceIfActivityTrackingEnabled (
60
+ devEnvClientStub as unknown as DevEnvClient ,
61
+ new ExtensionUserActivity ( 0 , [ userActivityEvent ] )
62
+ )
61
63
assert . strictEqual ( instance , undefined )
62
64
} )
63
65
64
66
describe ( 'activity subscribers are properly notified' , function ( ) {
65
- beforeEach ( function ( ) {
67
+ beforeEach ( function ( ) {
66
68
activitySubscriber = sandbox . stub ( )
67
69
devEnvActivity . onActivityUpdate ( activitySubscriber )
68
70
} )
@@ -81,10 +83,10 @@ describe('DevEnvActivity', function () {
81
83
82
84
it ( 'when we discover a different activity timestamp on the server' , async ( ) => {
83
85
assert . strictEqual ( activitySubscriber . callCount , 0 )
84
-
86
+
85
87
await devEnvActivity . sendActivityUpdate ( 111 ) // We send an activity update
86
88
assert . strictEqual ( activitySubscriber . callCount , 1 )
87
-
89
+
88
90
devEnvClientStub . getActivity . resolves ( 222 ) // If we retrieve the latest activity timestamp it will be different
89
91
await devEnvActivity . getLatestActivity ( )
90
92
assert . strictEqual ( activitySubscriber . callCount , 2 )
0 commit comments