33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
55
6+ import * as os from "os" ;
67import * as vscode from "vscode" ;
78import * as sinon from "sinon" ;
89import sinonChai from "sinon-chai" ;
@@ -18,6 +19,7 @@ import {
1819import { initializeIconUtils } from "./utils" ;
1920
2021chai . use ( sinonChai ) ;
22+ const tooltipLineSeparator = `${ os . EOL } ${ os . EOL } ` ;
2123
2224suite ( "Background Tasks Provider Tests" , ( ) => {
2325 let sandbox : sinon . SinonSandbox ;
@@ -69,7 +71,9 @@ suite("Background Tasks Provider Tests", () => {
6971 expect ( node . label ) . to . equal ( "Import complete" ) ;
7072 expect ( node . description ) . to . equal ( "100% | localhost/AdventureWorks2022 | 5s" ) ;
7173 expect ( node . tooltip ) . to . equal (
72- "Import finished\n\nIn progress\n\nCompleted successfully\n\nElapsed time: 5s" ,
74+ [ "Import finished" , "In progress" , "Completed successfully" , "Elapsed time: 5s" ] . join (
75+ tooltipLineSeparator ,
76+ ) ,
7377 ) ;
7478 expect ( ( node . iconPath as vscode . ThemeIcon ) . id ) . to . equal ( "pass" ) ;
7579 } ) ;
@@ -91,7 +95,9 @@ suite("Background Tasks Provider Tests", () => {
9195 expect ( nodes ) . to . have . length ( 1 ) ;
9296 expect ( node . description ) . to . equal ( "3s" ) ;
9397 expect ( node . contextValue ) . to . contain ( "completed=true" ) ;
94- expect ( node . tooltip ) . to . equal ( "Exporting\n\nSucceeded\n\nDone\n\nElapsed time: 3s" ) ;
98+ expect ( node . tooltip ) . to . equal (
99+ [ "Exporting" , "Succeeded" , "Done" , "Elapsed time: 3s" ] . join ( tooltipLineSeparator ) ,
100+ ) ;
95101 expect ( ( node . iconPath as vscode . ThemeIcon ) . id ) . to . equal ( "pass" ) ;
96102 expect ( ( node . iconPath as vscode . ThemeIcon ) . color ?. id ) . to . equal ( "testing.iconPassed" ) ;
97103 } ) ;
@@ -110,12 +116,15 @@ suite("Background Tasks Provider Tests", () => {
110116 const node = provider . getChildren ( ) [ 0 ] as BackgroundTaskNode ;
111117
112118 expect ( node . description ) . to . equal ( "250ms" ) ;
113- expect ( node . tooltip ) . to . equal ( "Running\n\nFailed\n\nFailed badly\n\nElapsed time: 250ms" ) ;
119+ expect ( node . tooltip ) . to . equal (
120+ [ "Running" , "Failed" , "Failed badly" , "Elapsed time: 250ms" ] . join ( tooltipLineSeparator ) ,
121+ ) ;
114122 expect ( ( node . iconPath as vscode . ThemeIcon ) . id ) . to . equal ( "error" ) ;
115123 expect ( ( node . iconPath as vscode . ThemeIcon ) . color ?. id ) . to . equal ( "testing.iconFailed" ) ;
116124 } ) ;
117125
118126 test ( "canceled tasks use the canceled theme icon" , ( ) => {
127+ sandbox . useFakeTimers ( ) ;
119128 const provider = new BackgroundTasksProvider ( ) ;
120129 const handle = provider . backgroundTasksService . registerTask ( {
121130 displayText : "Canceled task" ,
@@ -127,7 +136,9 @@ suite("Background Tasks Provider Tests", () => {
127136 const node = provider . getChildren ( ) [ 0 ] as BackgroundTaskNode ;
128137
129138 expect ( node . tooltip ) . to . equal (
130- "Running\n\nCanceled\n\nStopped by user\n\nElapsed time: 0ms" ,
139+ [ "Running" , "Canceled" , "Stopped by user" , "Elapsed time: 0ms" ] . join (
140+ tooltipLineSeparator ,
141+ ) ,
131142 ) ;
132143 expect ( ( node . iconPath as vscode . ThemeIcon ) . id ) . to . equal ( "circle-slash" ) ;
133144 } ) ;
@@ -148,7 +159,9 @@ suite("Background Tasks Provider Tests", () => {
148159
149160 node = provider . getChildren ( ) [ 0 ] as BackgroundTaskNode ;
150161 expect ( node . description ) . to . equal ( "1m 5s" ) ;
151- expect ( node . tooltip ) . to . equal ( "Working\n\nIn progress\n\nElapsed time: 01:05" ) ;
162+ expect ( node . tooltip ) . to . equal (
163+ [ "Working" , "In progress" , "Elapsed time: 01:05" ] . join ( tooltipLineSeparator ) ,
164+ ) ;
152165 } ) ;
153166
154167 test ( "clearFinished removes only completed tasks" , ( ) => {
@@ -248,6 +261,7 @@ suite("Background Tasks Provider Tests", () => {
248261 } ) ;
249262
250263 test ( "cancel command restores task state when the cancel callback fails" , async ( ) => {
264+ sandbox . useFakeTimers ( ) ;
251265 const provider = new BackgroundTasksProvider ( ) ;
252266 const cancelError = new Error ( "cancel failed" ) ;
253267 const handle = provider . backgroundTasksService . registerTask ( {
@@ -268,8 +282,8 @@ suite("Background Tasks Provider Tests", () => {
268282
269283 expect ( actualError ) . to . equal ( cancelError ) ;
270284 const refreshedNode = provider . getChildren ( ) [ 0 ] as BackgroundTaskNode ;
271- expect ( refreshedNode . tooltip ) . to . match (
272- / ^ C a n c e l a b l e \n \n I n p r o g r e s s \n \n E l a p s e d t i m e : \d + m s $ / ,
285+ expect ( refreshedNode . tooltip ) . to . equal (
286+ [ " Cancelable" , "In progress" , "Elapsed time: 0ms" ] . join ( tooltipLineSeparator ) ,
273287 ) ;
274288 expect ( refreshedNode . contextValue ) . to . contain ( "cancelable=true" ) ;
275289 handle . remove ( ) ;
0 commit comments