3
3
4
4
import * as assert from "assert" ;
5
5
import * as vscode from "vscode" ;
6
- import { suiteSetup , setup , teardown } from "mocha" ;
6
+ import { suiteSetup , setup , suiteTeardown , teardown } from "mocha" ;
7
7
import { ISECompatibilityFeature } from "../../src/features/ISECompatibility" ;
8
8
import utils = require( "../utils" ) ;
9
9
10
10
suite ( "ISECompatibility feature" , ( ) => {
11
- suiteSetup ( utils . ensureExtensionIsActivated ) ;
11
+ let currentTheme : string ;
12
+
13
+ suiteSetup ( async ( ) => {
14
+ // Save user's current theme.
15
+ currentTheme = await vscode . workspace . getConfiguration ( "workbench" ) . get ( "colorTheme" ) ;
16
+ await utils . ensureExtensionIsActivated ( ) ;
17
+ } ) ;
18
+
12
19
setup ( async ( ) => { await vscode . commands . executeCommand ( "PowerShell.EnableISEMode" ) ; } ) ;
20
+
13
21
teardown ( async ( ) => { await vscode . commands . executeCommand ( "PowerShell.DisableISEMode" ) ; } ) ;
14
22
23
+ suiteTeardown ( async ( ) => {
24
+ // Reset user's current theme.
25
+ await vscode . workspace . getConfiguration ( "workbench" ) . update ( "colorTheme" , currentTheme , true ) ;
26
+ assert . strictEqual ( vscode . workspace . getConfiguration ( "workbench" ) . get ( "colorTheme" ) , currentTheme ) ;
27
+ } ) ;
28
+
15
29
test ( "It sets ISE Settings" , async ( ) => {
16
30
for ( const iseSetting of ISECompatibilityFeature . settings ) {
17
31
const currently = vscode . workspace . getConfiguration ( iseSetting . path ) . get ( iseSetting . name ) ;
@@ -31,15 +45,18 @@ suite("ISECompatibility feature", () => {
31
45
}
32
46
} ) . timeout ( 10000 ) ;
33
47
34
- test ( "It leaves Theme after being changed after enabling ISE Mode " , async ( ) => {
48
+ test ( "It doesn't change theme when disabled if theme was manually changed after being enabled " , async ( ) => {
35
49
assert . strictEqual ( vscode . workspace . getConfiguration ( "workbench" ) . get ( "colorTheme" ) , "PowerShell ISE" ) ;
36
50
37
- await vscode . workspace . getConfiguration ( "workbench" ) . update ( "colorTheme" , "Dark+" , true ) ;
51
+ // "Manually" change theme after enabling ISE mode. Use a built-in theme but not the default.
52
+ await vscode . workspace . getConfiguration ( "workbench" ) . update ( "colorTheme" , "Monokai" , true ) ;
53
+ assert . strictEqual ( vscode . workspace . getConfiguration ( "workbench" ) . get ( "colorTheme" ) , "Monokai" ) ;
54
+
38
55
await vscode . commands . executeCommand ( "PowerShell.DisableISEMode" ) ;
39
56
for ( const iseSetting of ISECompatibilityFeature . settings ) {
40
57
const currently = vscode . workspace . getConfiguration ( iseSetting . path ) . get ( iseSetting . name ) ;
41
58
assert . notStrictEqual ( currently , iseSetting . value ) ;
42
59
}
43
- assert . strictEqual ( vscode . workspace . getConfiguration ( "workbench" ) . get ( "colorTheme" ) , "Dark+ " ) ;
60
+ assert . strictEqual ( vscode . workspace . getConfiguration ( "workbench" ) . get ( "colorTheme" ) , "Monokai " ) ;
44
61
} ) . timeout ( 10000 ) ;
45
62
} ) ;
0 commit comments