import * as vscode from 'vscode' ; import { nls } from '../../messages' ; import { TestExecutionInfo } from '../types' ; import { getIconPath } from './iconPaths' ; /**
 * Base class for test node in the test explorer.
 * It's initialized with the command to navigate to the test
 * upon clicking.
 */ export abstract class TestNode extends vscode . TreeItem { public description : string ; public location ? : vscode . Location ; public iconPath = getIconPath ( ) ; constructor ( label , collapsibleState , location ? ) { super ( label , collapsibleState ) ; this . location = location ; this . description = label ; this . command = { command : 'sfdx.force.lightning.lwc.test.navigateToTest' , title : nls . localize ( 'force_lightning_lwc_test_navigate_to_test' ) , arguments : [ this ] } ; } } /**
 * Test Node representing an individual test case.
 */ export class SfdxTestNode extends TestNode { public contextValue ? : string ; public testExecutionInfo ? : TestExecutionInfo ; constructor ( label , testExecutionInfo ? ) { super ( label , vscode . TreeItemCollapsibleState . None ) ; this . testExecutionInfo = testExecutionInfo ; if ( testExecutionInfo ) { const { testType , testResult } = testExecutionInfo ; this . contextValue = `${ testType }Test` ; this . iconPath = getIconPath ( testResult ) ; if ( 'testLocation' in testExecutionInfo ) { this . location = testExecutionInfo . testLocation ; } } } } /**
 * Test Group Node representing a test file.
 * By default it's collpased
 */ export class SfdxTestGroupNode extends TestNode { public contextValue ? : string ; public testExecutionInfo ? : TestExecutionInfo ; constructor ( label , testExecutionInfo , collapsibleState = vscode . TreeItemCollapsibleState . Collapsed ) { super ( label , collapsibleState ) ; this . testExecutionInfo = testExecutionInfo ; if ( testExecutionInfo ) { const { testType , testResult } = testExecutionInfo ; this . contextValue = `${ testType }TestGroup` ; this . iconPath = getIconPath ( testResult ) ; if ( 'testLocation' in testExecutionInfo ) { this . location = testExecutionInfo . testLocation ; } } } } param node1 param node2 export function sortTestNodeByLabel ( node1 , node2 ) { const label1 = node1 ! . label ; const label2 = node2 ! . label ; if ( ! label1 ) { return - 1 ; } if ( ! label2 ) { return 1 ; } return label1 . localeCompare ( label2 ) ; }