@@ -148,57 +148,77 @@ suite("Extension Test Suite", () => {
148
148
} ) ;
149
149
150
150
suite ( "randomCase" , ( ) => {
151
- const input = "Hello, World!" ;
151
+ const input = "Hello, World!" ;
152
152
153
- test ( "returns a string of the same length" , ( ) => {
154
- const output = myExtension . commandNameFunctionMap [ "randomCase" ] (
155
- input
156
- ) as string ;
157
- assert . equal ( output . length , input . length ) ;
158
- } ) ;
159
-
160
- test ( "contains the same characters ignoring case" , ( ) => {
161
- const output = myExtension . commandNameFunctionMap [ "randomCase" ] (
162
- input
163
- ) as string ;
164
- assert . equal ( output . toLowerCase ( ) , input . toLowerCase ( ) ) ;
165
- } ) ;
153
+ test ( "returns a string of the same length" , ( ) => {
154
+ const output = myExtension . commandNameFunctionMap [ "randomCase" ] (
155
+ input
156
+ ) as string ;
157
+ assert . equal ( output . length , input . length ) ;
158
+ } ) ;
166
159
167
- test ( "changes the case of at least one character (statistically)" , ( ) => {
168
- let changed = false ;
169
- for ( let i = 0 ; i < 10 ; i ++ ) {
160
+ test ( "contains the same characters ignoring case" , ( ) => {
170
161
const output = myExtension . commandNameFunctionMap [ "randomCase" ] (
171
162
input
172
163
) as string ;
173
- if ( output !== input && output . toLowerCase ( ) === input . toLowerCase ( ) ) {
174
- changed = true ;
175
- break ;
164
+ assert . equal ( output . toLowerCase ( ) , input . toLowerCase ( ) ) ;
165
+ } ) ;
166
+
167
+ test ( "changes the case of at least one character (statistically)" , ( ) => {
168
+ let changed = false ;
169
+ for ( let i = 0 ; i < 10 ; i ++ ) {
170
+ const output = myExtension . commandNameFunctionMap [ "randomCase" ] (
171
+ input
172
+ ) as string ;
173
+ if (
174
+ output !== input &&
175
+ output . toLowerCase ( ) === input . toLowerCase ( )
176
+ ) {
177
+ changed = true ;
178
+ break ;
179
+ }
176
180
}
177
- }
178
- assert . equal ( changed , true ) ;
179
- } ) ;
181
+ assert . equal ( changed , true ) ;
182
+ } ) ;
180
183
181
- test ( "handles empty strings" , ( ) => {
182
- const output = myExtension . commandNameFunctionMap . randomCase ( "" ) ;
183
- assert . equal ( output , "" ) ;
184
- } ) ;
184
+ test ( "handles empty strings" , ( ) => {
185
+ const output = myExtension . commandNameFunctionMap . randomCase ( "" ) ;
186
+ assert . equal ( output , "" ) ;
187
+ } ) ;
185
188
186
- test ( "preserves non-alphabetic characters" , ( ) => {
187
- const specialChars = "12345!@#$%" ;
188
- const output =
189
- myExtension . commandNameFunctionMap . randomCase ( specialChars ) ;
190
- assert . equal ( output , specialChars ) ;
189
+ test ( "preserves non-alphabetic characters" , ( ) => {
190
+ const specialChars = "12345!@#$%" ;
191
+ const output =
192
+ myExtension . commandNameFunctionMap . randomCase ( specialChars ) ;
193
+ assert . equal ( output , specialChars ) ;
194
+ } ) ;
195
+
196
+ test ( "handles strings with mixed content" , ( ) => {
197
+ const mixedInput = "Test123!" ;
198
+ const output = myExtension . commandNameFunctionMap . randomCase (
199
+ mixedInput
200
+ ) as string ;
201
+ assert . equal ( output . length , mixedInput . length ) ;
202
+ assert . notEqual ( output . replace ( / [ ^ a - z A - Z ] / g, "" ) , "" ) ;
203
+ } ) ;
191
204
} ) ;
205
+ } ) ;
206
+
207
+ suite ( "activation events" , ( ) => {
208
+ const extension = vscode . extensions . getExtension (
209
+ "marclipovsky.string-manipulation"
210
+ ) ! ;
192
211
193
- test ( "handles strings with mixed content" , ( ) => {
194
- const mixedInput = "Test123!" ;
195
- const output = myExtension . commandNameFunctionMap . randomCase (
196
- mixedInput
197
- ) as string ;
198
- assert . equal ( output . length , mixedInput . length ) ;
199
- assert . notEqual ( output . replace ( / [ ^ a - z A - Z ] / g, "" ) , "" ) ;
212
+ test ( "is not active by default" , ( ) => {
213
+ const extension = vscode . extensions . getExtension (
214
+ "marclipovsky.string-manipulation"
215
+ ) ! ;
216
+ assert . equal ( false , extension . isActive ) ;
200
217
} ) ;
201
218
202
- } ) ;
219
+ test ( "invoked when running one of the commands" , async ( ) => {
220
+ await vscode . commands . executeCommand ( "string-manipulation.titleize" ) ;
221
+ assert . equal ( true , extension . isActive ) ;
222
+ } ) ;
203
223
} ) ;
204
224
} ) ;
0 commit comments