33
44import * as assert from "assert" ;
55import * as vscode from "vscode" ;
6- import { suiteSetup , setup , teardown } from "mocha" ;
6+ import { suiteSetup , setup , suiteTeardown , teardown } from "mocha" ;
77import { ISECompatibilityFeature } from "../../src/features/ISECompatibility" ;
88import utils = require( "../utils" ) ;
99
1010suite ( "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+
1219 setup ( async ( ) => { await vscode . commands . executeCommand ( "PowerShell.EnableISEMode" ) ; } ) ;
20+
1321 teardown ( async ( ) => { await vscode . commands . executeCommand ( "PowerShell.DisableISEMode" ) ; } ) ;
1422
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+
1529 test ( "It sets ISE Settings" , async ( ) => {
1630 for ( const iseSetting of ISECompatibilityFeature . settings ) {
1731 const currently = vscode . workspace . getConfiguration ( iseSetting . path ) . get ( iseSetting . name ) ;
@@ -31,15 +45,18 @@ suite("ISECompatibility feature", () => {
3145 }
3246 } ) . timeout ( 10000 ) ;
3347
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 ( ) => {
3549 assert . strictEqual ( vscode . workspace . getConfiguration ( "workbench" ) . get ( "colorTheme" ) , "PowerShell ISE" ) ;
3650
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+
3855 await vscode . commands . executeCommand ( "PowerShell.DisableISEMode" ) ;
3956 for ( const iseSetting of ISECompatibilityFeature . settings ) {
4057 const currently = vscode . workspace . getConfiguration ( iseSetting . path ) . get ( iseSetting . name ) ;
4158 assert . notStrictEqual ( currently , iseSetting . value ) ;
4259 }
43- assert . strictEqual ( vscode . workspace . getConfiguration ( "workbench" ) . get ( "colorTheme" ) , "Dark+ " ) ;
60+ assert . strictEqual ( vscode . workspace . getConfiguration ( "workbench" ) . get ( "colorTheme" ) , "Monokai " ) ;
4461 } ) . timeout ( 10000 ) ;
4562} ) ;
0 commit comments