33
44'use strict' ;
55
6- // tslint:disable:no-any no- unused-expression chai-vague-errors no-unnecessary-override max-func-body-length max-classes-per-file
6+ // tslint:disable:no-unused-expression chai-vague-errors no-unnecessary-override max-func-body-length max-classes-per-file match-default-export-name
77
88import { expect } from 'chai' ;
99import * as path from 'path' ;
10+ import rewiremock from 'rewiremock' ;
11+ import * as sinon from 'sinon' ;
1012import { ConfigurationTarget , Disposable } from 'vscode' ;
1113import { Diagnostics } from '../client/common/utils/localize' ;
1214import { EXTENSION_ROOT_DIR } from '../client/constants' ;
@@ -22,6 +24,7 @@ suite('Source Map Support', () => {
2224 } ;
2325 const vscode = {
2426 workspace : {
27+ // tslint:disable-next-line: no-any
2528 getConfiguration : ( setting : string , _defaultValue : any ) => {
2629 if ( setting !== 'python.diagnostics' ) {
2730 return ;
@@ -52,6 +55,7 @@ suite('Source Map Support', () => {
5255
5356 const disposables : Disposable [ ] = [ ] ;
5457 teardown ( ( ) => {
58+ rewiremock . disable ( ) ;
5559 disposables . forEach ( disposable => {
5660 try {
5761 disposable . dispose ( ) ;
@@ -60,19 +64,26 @@ suite('Source Map Support', () => {
6064 } ) ;
6165 test ( 'Test message is not displayed when source maps are not enabled' , async ( ) => {
6266 const stub = createVSCStub ( false ) ;
67+ // tslint:disable-next-line: no-any
6368 initialize ( stub . vscode as any ) ;
6469 await sleep ( 100 ) ;
6570 expect ( stub . stubInfo . configValueRetrieved ) . to . be . equal ( true , 'Config Value not retrieved' ) ;
6671 expect ( stub . stubInfo . messageDisplayed ) . to . be . equal ( false , 'Message displayed' ) ;
6772 } ) ;
68- test ( 'Test message is not displayed when source maps are not enabled' , async ( ) => {
73+ test ( 'Test message is displayed when source maps are not enabled' , async ( ) => {
6974 const stub = createVSCStub ( true ) ;
7075 const instance = new class extends SourceMapSupport {
7176 protected async enableSourceMaps ( _enable : boolean ) {
7277 noop ( ) ;
7378 }
79+ // tslint:disable-next-line: no-any
7480 } ( stub . vscode as any ) ;
81+ rewiremock . enable ( ) ;
82+ const installStub = sinon . stub ( ) ;
83+ rewiremock ( 'source-map-support' ) . with ( { install : installStub } ) ;
7584 await instance . initialize ( ) ;
85+
86+ expect ( installStub . callCount ) . to . be . equal ( 1 ) ;
7687 expect ( stub . stubInfo . configValueRetrieved ) . to . be . equal ( true , 'Config Value not retrieved' ) ;
7788 expect ( stub . stubInfo . messageDisplayed ) . to . be . equal ( true , 'Message displayed' ) ;
7889 expect ( stub . stubInfo . configValueUpdated ) . to . be . equal ( false , 'Config Value updated' ) ;
@@ -83,6 +94,7 @@ suite('Source Map Support', () => {
8394 protected async enableSourceMaps ( _enable : boolean ) {
8495 noop ( ) ;
8596 }
97+ // tslint:disable-next-line: no-any
8698 } ( stub . vscode as any ) ;
8799
88100 await instance . initialize ( ) ;
@@ -102,6 +114,7 @@ suite('Source Map Support', () => {
102114 sourceFilesPassed . push ( sourceFile ) ;
103115 return Promise . resolve ( ) ;
104116 }
117+ // tslint:disable-next-line: no-any
105118 } ( stub . vscode as any ) ;
106119
107120 await instance . enableSourceMaps ( enableSourceMaps ) ;
0 commit comments