1- import * as assert from 'assert' ;
1+ import { ok } from 'node: assert' ;
22import * as vscode from 'vscode' ;
33
44const FIXTURE_RELATIVE_PATH = 'app/views/example.html.erb' ;
55
66suite ( 'ERB Inline JS Helper - Happy Path' , ( ) => {
77 let document : vscode . TextDocument ;
88
9- suiteSetup ( async function ( ) {
9+ suiteSetup ( async ( ) => {
1010 const workspaceRoot = vscode . workspace . workspaceFolders ?. [ 0 ] ?. uri . fsPath ;
11- assert . ok ( workspaceRoot , 'Workspace is not open' ) ;
11+ ok ( workspaceRoot , 'Workspace is not open' ) ;
1212
1313 document = await vscode . workspace . openTextDocument ( vscode . Uri . file ( `${ workspaceRoot } /${ FIXTURE_RELATIVE_PATH } ` ) ) ;
1414
1515 const extension = vscode . extensions . getExtension ( 'kudoas.erb-inline-js-helper' ) ;
16- assert . ok ( extension , 'Extension is not found' ) ;
16+ ok ( extension , 'Extension is not found' ) ;
1717 await extension . activate ( ) ;
18- assert . ok ( extension . isActive , 'Extension did not activate' ) ;
18+ ok ( extension . isActive , 'Extension did not activate' ) ;
1919 } ) ;
2020
21- test ( 'extension activates' , async function ( ) {
21+ test ( 'extension activates' , async ( ) => {
2222 const extension = vscode . extensions . getExtension ( 'kudoas.erb-inline-js-helper' ) ;
2323
24- assert . ok ( extension , 'Extension is not found' ) ;
24+ ok ( extension , 'Extension is not found' ) ;
2525 await extension . activate ( ) ;
26- assert . ok ( extension . isActive , 'Extension did not activate' ) ;
26+ ok ( extension . isActive , 'Extension did not activate' ) ;
2727 } ) ;
2828
29- test ( 'completion provides console.log' , async function ( ) {
29+ test ( 'completion provides console.log' , async ( ) => {
3030 const position = positionAtSubstring ( document , 'console.' , 0 , 'completion target' , 'after' ) ;
3131
3232 const list = await vscode . commands . executeCommand < vscode . CompletionList > (
@@ -36,29 +36,29 @@ suite('ERB Inline JS Helper - Happy Path', () => {
3636 '.'
3737 ) ;
3838
39- assert . ok ( list , 'Completion list is undefined' ) ;
39+ ok ( list , 'Completion list is undefined' ) ;
4040 const labels = list . items . map ( ( item ) => ( typeof item . label === 'string' ? item . label : item . label . label ) ) ;
41- assert . ok ( labels . includes ( 'log' ) , 'Expected "log" in completion items' ) ;
41+ ok ( labels . includes ( 'log' ) , 'Expected "log" in completion items' ) ;
4242 } ) ;
4343
44- test ( 'hover shows info for message' , async function ( ) {
44+ test ( 'hover shows info for message' , async ( ) => {
4545 const position = positionAtSubstring ( document , 'message' , 0 , 'hover target' ) ;
4646 const hovers = await vscode . commands . executeCommand < vscode . Hover [ ] > (
4747 'vscode.executeHoverProvider' ,
4848 document . uri ,
4949 position
5050 ) ;
5151
52- assert . ok ( hovers && hovers . length > 0 , 'Hover is empty' ) ;
52+ ok ( hovers && hovers . length > 0 , 'Hover is empty' ) ;
5353 const text = hovers
5454 . flatMap ( ( hover ) => hover . contents )
5555 . map ( ( content ) => ( typeof content === 'string' ? content : content . value ) )
5656 . join ( ' ' ) ;
5757
58- assert . ok ( text . includes ( 'message' ) , 'Hover does not mention "message"' ) ;
58+ ok ( text . includes ( 'message' ) , 'Hover does not mention "message"' ) ;
5959 } ) ;
6060
61- test ( 'definition points to message declaration' , async function ( ) {
61+ test ( 'definition points to message declaration' , async ( ) => {
6262 const usageLineIndex = indexOfSubstring ( document , 'console.log(message);' , 0 , 'definition usage line' ) ;
6363 const usageNameIndex = indexOfSubstring ( document , 'message' , usageLineIndex , 'definition usage' ) ;
6464 const usagePosition = document . positionAt ( usageNameIndex ) ;
@@ -67,7 +67,7 @@ suite('ERB Inline JS Helper - Happy Path', () => {
6767 > ( 'vscode.executeDefinitionProvider' , document . uri , usagePosition ) ;
6868
6969 const locations = normalizeLocations ( definitions ) ;
70- assert . ok ( locations . length > 0 , 'Definition result is empty' ) ;
70+ ok ( locations . length > 0 , 'Definition result is empty' ) ;
7171
7272 const declarationLineIndex = indexOfSubstring ( document , 'const message' , 0 , 'definition declaration' ) ;
7373 const declarationNameIndex = indexOfSubstring (
@@ -83,7 +83,7 @@ suite('ERB Inline JS Helper - Happy Path', () => {
8383 location . uri . toString ( ) === document . uri . toString ( ) && location . range . start . isEqual ( declarationNamePosition )
8484 ) ;
8585
86- assert . ok ( match , 'Definition did not resolve to the message declaration' ) ;
86+ ok ( match , 'Definition did not resolve to the message declaration' ) ;
8787 } ) ;
8888} ) ;
8989
@@ -102,7 +102,7 @@ function positionAtSubstring(
102102function indexOfSubstring ( document : vscode . TextDocument , substring : string , fromIndex : number , label : string ) : number {
103103 const text = document . getText ( ) ;
104104 const index = text . indexOf ( substring , fromIndex ) ;
105- assert . ok ( index !== - 1 , `Missing substring for ${ label } : ${ substring } ` ) ;
105+ ok ( index !== - 1 , `Missing substring for ${ label } : ${ substring } ` ) ;
106106 return index ;
107107}
108108
0 commit comments