@@ -24,6 +24,7 @@ import {
2424 env ,
2525 window ,
2626 workspace ,
27+ TreeItem ,
2728} from "vscode" ;
2829
2930import { InsightsConnection } from "../../src/classes/insightsConnection" ;
@@ -45,6 +46,7 @@ import { ChartEditorProvider } from "../../src/services/chartEditorProvider";
4546import { CompletionProvider } from "../../src/services/completionProvider" ;
4647import { ConnectionManagementService } from "../../src/services/connectionManagerService" ;
4748import { DataSourceEditorProvider } from "../../src/services/dataSourceEditorProvider" ;
49+ import { HelpFeedbackProvider } from "../../src/services/helpFeedbackProvider" ;
4850import {
4951 getCurrentToken ,
5052 refreshToken ,
@@ -2537,3 +2539,92 @@ describe("kdbTreeService", () => {
25372539 sinon . restore ( ) ;
25382540 } ) ;
25392541} ) ;
2542+
2543+ describe ( "HelpFeedbackProvider" , ( ) => {
2544+ let provider : HelpFeedbackProvider ;
2545+
2546+ beforeEach ( ( ) => {
2547+ provider = new HelpFeedbackProvider ( ) ;
2548+ } ) ;
2549+
2550+ it ( "should return all help items in getChildren" , ( ) => {
2551+ const children = provider . getChildren ( ) ;
2552+ assert . strictEqual ( children . length , 4 ) ;
2553+ assert ( children [ 0 ] instanceof TreeItem ) ;
2554+ assert . strictEqual ( children [ 0 ] . label , "Extension Documentation" ) ;
2555+ assert . strictEqual ( children [ 1 ] . label , "Suggest a Feature" ) ;
2556+ assert . strictEqual ( children [ 2 ] . label , "Provide Feedback" ) ;
2557+ assert . strictEqual ( children [ 3 ] . label , "Report a Bug" ) ;
2558+ } ) ;
2559+
2560+ it ( "should return the same item in getTreeItem" , ( ) => {
2561+ const children = provider . getChildren ( ) ;
2562+ for ( const item of children ) {
2563+ const treeItem = provider . getTreeItem ( item ) ;
2564+ assert . strictEqual ( treeItem , item ) ;
2565+ }
2566+ } ) ;
2567+
2568+ it ( "should set correct command and iconPath for each HelpItem" , ( ) => {
2569+ const children = provider . getChildren ( ) ;
2570+ const expected = [
2571+ {
2572+ label : "Extension Documentation" ,
2573+ command : "kdb.help.openDocumentation" ,
2574+ icon : "help-doc.svg" ,
2575+ } ,
2576+ {
2577+ label : "Suggest a Feature" ,
2578+ command : "kdb.help.suggestFeature" ,
2579+ icon : "feature.svg" ,
2580+ } ,
2581+ {
2582+ label : "Provide Feedback" ,
2583+ command : "kdb.help.provideFeedback" ,
2584+ icon : "feedback.svg" ,
2585+ } ,
2586+ {
2587+ label : "Report a Bug" ,
2588+ command : "kdb.help.reportBug" ,
2589+ icon : "bug.svg" ,
2590+ } ,
2591+ ] ;
2592+
2593+ children . forEach ( ( item , idx ) => {
2594+ assert . strictEqual ( item . label , expected [ idx ] . label ) ;
2595+ assert . deepStrictEqual ( item . command , {
2596+ command : expected [ idx ] . command ,
2597+ title : expected [ idx ] . label ,
2598+ } ) ;
2599+ if (
2600+ typeof item . iconPath === "object" &&
2601+ item . iconPath !== null &&
2602+ "light" in item . iconPath &&
2603+ "dark" in item . iconPath
2604+ ) {
2605+ assert . ok (
2606+ String ( item . iconPath . light ) . endsWith (
2607+ Path . join ( "resources" , "light" , expected [ idx ] . icon ) ,
2608+ ) ,
2609+ ) ;
2610+ assert . ok (
2611+ String ( item . iconPath . dark ) . endsWith (
2612+ Path . join ( "resources" , "dark" , expected [ idx ] . icon ) ,
2613+ ) ,
2614+ ) ;
2615+ }
2616+ } ) ;
2617+ } ) ;
2618+
2619+ it ( "should emit onDidChangeTreeData event" , ( done ) => {
2620+ const spy = sinon . spy ( ) ;
2621+ provider . onDidChangeTreeData ( spy ) ;
2622+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2623+ // @ts -ignore: Accessing private member for test
2624+ provider . _onDidChangeTreeData . fire ( ) ;
2625+ setTimeout ( ( ) => {
2626+ assert . ok ( spy . calledOnce ) ;
2627+ done ( ) ;
2628+ } , 10 ) ;
2629+ } ) ;
2630+ } ) ;
0 commit comments