@@ -2,23 +2,9 @@ import * as assert from "assert";
22import { suite , test , beforeEach , afterEach } from "mocha" ;
33import * as vscode from "vscode" ;
44import { RubyEnvironment } from "../rubyEnvironment" ;
5+ import { FakeContext , createContext } from "./helpers" ;
56
67suite ( "RubyEnvironment Test Suite" , ( ) => {
7- type FakeContext = vscode . ExtensionContext & { dispose : ( ) => void } ;
8-
9- function createContext ( ) {
10- const subscriptions : vscode . Disposable [ ] = [ ] ;
11-
12- return {
13- subscriptions,
14- dispose : ( ) => {
15- subscriptions . forEach ( ( subscription ) => {
16- subscription . dispose ( ) ;
17- } ) ;
18- } ,
19- } as unknown as FakeContext ;
20- }
21-
228 function createMockLogger ( ) : vscode . LogOutputChannel {
239 return {
2410 info : ( ) => { } ,
@@ -50,14 +36,27 @@ suite("RubyEnvironment Test Suite", () => {
5036 assert . strictEqual ( typeof rubyEnvironment . getRuby , "function" , "getRuby should be a function" ) ;
5137 } ) ;
5238
53- test ( "registers config watcher, status item, and command subscriptions" , ( ) => {
54- new RubyEnvironment ( context , mockLogger ) ;
39+ suite ( "activate" , ( ) => {
40+ test ( "registers config watcher, status item, and command subscriptions" , async ( ) => {
41+ const rubyEnvironment = new RubyEnvironment ( context , mockLogger ) ;
42+
43+ await rubyEnvironment . activate ( ) ;
5544
56- assert . strictEqual (
57- context . subscriptions . length ,
58- 3 ,
59- "Extension should register three subscriptions (status item, config watcher, and command)" ,
60- ) ;
45+ assert . strictEqual (
46+ context . subscriptions . length ,
47+ 3 ,
48+ "Extension should register three subscriptions (status item, config watcher, and command)" ,
49+ ) ;
50+ } ) ;
51+
52+ test ( "registers selectRubyVersion command" , async ( ) => {
53+ const rubyEnvironment = new RubyEnvironment ( context , mockLogger ) ;
54+
55+ await rubyEnvironment . activate ( ) ;
56+
57+ const commands = await vscode . commands . getCommands ( true ) ;
58+ assert . ok ( commands . includes ( "ruby-environments.selectRubyVersion" ) , "Command should be registered" ) ;
59+ } ) ;
6160 } ) ;
6261
6362 test ( "returns initial Ruby definition from configuration" , ( ) => {
@@ -68,12 +67,5 @@ suite("RubyEnvironment Test Suite", () => {
6867 // Since no configuration is set in tests, it should return null
6968 assert . strictEqual ( result , null , "getRuby should return null when no configuration is set" ) ;
7069 } ) ;
71-
72- test ( "registers selectRubyVersion command" , async ( ) => {
73- new RubyEnvironment ( context , mockLogger ) ;
74-
75- const commands = await vscode . commands . getCommands ( true ) ;
76- assert . ok ( commands . includes ( "ruby-environments.selectRubyVersion" ) , "Command should be registered" ) ;
77- } ) ;
7870 } ) ;
7971} ) ;
0 commit comments