@@ -3,35 +3,52 @@ import { join } from 'node:path'
33import { describe , it , expect , vi } from 'vitest'
44import * as vscode from 'vscode'
55
6- import { convertPathToUri , isCucumberFeatureFile } from '../src/converter.js'
6+ import { convertPathToUri , convertSourceRangeToVSCodeRange , isCucumberFeatureFile } from '../src/converter.js'
77
88// Mock dependencies
99vi . mock ( 'vscode' , ( ) => import ( '../../../tests/__mocks__/vscode.cjs' ) )
1010vi . mock ( '@vscode-wdio/logger' , ( ) => import ( '../../../tests/__mocks__/logger.js' ) )
1111
12- describe ( 'Converter' , ( ) => {
13- describe ( 'convertPathToUri' , ( ) => {
14- it ( 'should convert file path to VSCode URI' , ( ) => {
15- const filePath = join ( process . cwd ( ) , 'path' , 'to' , 'spec.js' )
16- const result = convertPathToUri ( filePath )
12+ describe ( 'convertSourceRangeToVSCodeRange' , ( ) => {
13+ it ( 'should convert range to VSCode.Range' , ( ) => {
14+ const sourceRange = {
15+ start : {
16+ line : 1 ,
17+ column : 1 ,
18+ } ,
19+ end : {
20+ line : 10 ,
21+ column : 10 ,
22+ } ,
23+ }
24+ const result = convertSourceRangeToVSCodeRange ( sourceRange )
1725
18- expect ( result . scheme ) . toEqual ( 'file' )
19- expect ( result . fsPath ) . toEqual ( vscode . Uri . file ( filePath ) . fsPath )
20- } )
26+ expect ( result . start . line ) . toEqual ( 1 )
27+ expect ( result . end . line ) . toEqual ( 10 )
28+ } )
29+ } )
30+
31+ describe ( 'convertPathToUri' , ( ) => {
32+ it ( 'should convert file path to VSCode URI' , ( ) => {
33+ const filePath = join ( process . cwd ( ) , 'path' , 'to' , 'spec.js' )
34+ const result = convertPathToUri ( filePath )
35+
36+ expect ( result . scheme ) . toEqual ( 'file' )
37+ expect ( result . fsPath ) . toEqual ( vscode . Uri . file ( filePath ) . fsPath )
38+ } )
39+ } )
40+
41+ describe ( 'isCucumberFeatureFile' , ( ) => {
42+ it ( 'should return true for .feature files' , ( ) => {
43+ expect ( isCucumberFeatureFile ( '/path/to/test.feature' ) ) . toBe ( true )
44+ expect ( isCucumberFeatureFile ( '/path/to/TEST.FEATURE' ) ) . toBe ( true )
45+ expect ( isCucumberFeatureFile ( 'test.feature' ) ) . toBe ( true )
2146 } )
2247
23- describe ( 'isCucumberFeatureFile' , ( ) => {
24- it ( 'should return true for .feature files' , ( ) => {
25- expect ( isCucumberFeatureFile ( '/path/to/test.feature' ) ) . toBe ( true )
26- expect ( isCucumberFeatureFile ( '/path/to/TEST.FEATURE' ) ) . toBe ( true )
27- expect ( isCucumberFeatureFile ( 'test.feature' ) ) . toBe ( true )
28- } )
29-
30- it ( 'should return false for non-feature files' , ( ) => {
31- expect ( isCucumberFeatureFile ( '/path/to/test.js' ) ) . toBe ( false )
32- expect ( isCucumberFeatureFile ( '/path/to/test.ts' ) ) . toBe ( false )
33- expect ( isCucumberFeatureFile ( '/path/to/test.featurex' ) ) . toBe ( false )
34- expect ( isCucumberFeatureFile ( '/path/to/test' ) ) . toBe ( false )
35- } )
48+ it ( 'should return false for non-feature files' , ( ) => {
49+ expect ( isCucumberFeatureFile ( '/path/to/test.js' ) ) . toBe ( false )
50+ expect ( isCucumberFeatureFile ( '/path/to/test.ts' ) ) . toBe ( false )
51+ expect ( isCucumberFeatureFile ( '/path/to/test.featurex' ) ) . toBe ( false )
52+ expect ( isCucumberFeatureFile ( '/path/to/test' ) ) . toBe ( false )
3653 } )
3754} )
0 commit comments