@@ -21,6 +21,16 @@ function! s:SetJavascriptCommand()
21
21
endif
22
22
endfunction
23
23
24
+ " Set Javascript Debug
25
+ function ! s: SetJavascriptDebugCommand ()
26
+ if ! exists (" g:mocha_debug_command" )
27
+ let s: cmd = " mocha debug {spec}"
28
+ call s: GUIRunning ()
29
+ else
30
+ let g: spec_command = g: mocha_debug_command
31
+ endif
32
+ endfunction
33
+
24
34
" Set Coffeescript
25
35
function ! s: SetCoffeescriptCommand ()
26
36
if ! exists (" g:mocha_coffee_command" )
@@ -39,6 +49,10 @@ function! s:SetInitialSpecCommand()
39
49
call s: SetRubyCommand ()
40
50
elseif l: filetype = ~ ' js'
41
51
call s: SetJavascriptCommand ()
52
+ elseif l: filetype = ~ ' tsx'
53
+ call s: SetJavascriptCommand ()
54
+ elseif l: filetype = ~ ' ts'
55
+ call s: SetJavascriptCommand ()
42
56
elseif l: filetype = ~ ' coffee'
43
57
call s: SetCoffeescriptCommand ()
44
58
else
@@ -47,13 +61,18 @@ function! s:SetInitialSpecCommand()
47
61
endfunction
48
62
49
63
" Determine which command based on filetype
50
- function ! s: GetCorrectCommand ()
64
+ function ! s: GetCorrectCommand (debug )
51
65
" Set default {rspec} command (ruby/rails)
52
66
if &filetype == ? ' ruby'
53
67
call s: SetRubyCommand ()
54
- " Set default {mocha} command (javascript)
55
- elseif &filetype == ? ' javascript'
56
- call s: SetJavascriptCommand ()
68
+ " Set default {mocha} command (javascript)
69
+ elseif &filetype == ? ' javascript' || &filetype == ? ' typescript.tsx' || &filetype == ? ' typescript'
70
+ " set debug command here
71
+ if a: debug
72
+ call s: SetJavascriptDebugCommand ()
73
+ else
74
+ call s: SetJavascriptCommand ()
75
+ endif
57
76
" Set default {mocha} command (coffeescript)
58
77
elseif &filetype == ? ' coffee'
59
78
call s: SetCoffeescriptCommand ()
@@ -106,29 +125,29 @@ function! RunAllSpecs()
106
125
else
107
126
let l: spec = " "
108
127
endif
109
- call RunSpecs (l: spec )
128
+ call RunSpecs (l: spec, 0 )
110
129
endfunction
111
130
112
131
" Current File
113
132
function ! RunCurrentSpecFile ()
114
133
if InSpecFile ()
115
134
let l: spec = @%
116
- call RunSpecs (l: spec )
135
+ call RunSpecs (l: spec, 0 )
117
136
else
118
137
call RunLastSpec ()
119
138
endif
120
139
endfunction
121
140
122
141
" Nearest Spec
123
- function ! RunNearestSpec ()
142
+ function ! RunNearestSpec (debug )
124
143
if InSpecFile ()
125
144
if &filetype == ? " ruby"
126
145
let l: spec = @% . " :" . line (" ." )
127
146
else
128
147
call s: GetNearestTest ()
129
148
let l: spec = @% . " -g '" . s: nearestTest . " '"
130
149
end
131
- call RunSpecs (l: spec )
150
+ call RunSpecs (l: spec, a: debug )
132
151
else
133
152
call RunLastSpec ()
134
153
endif
@@ -143,7 +162,7 @@ endfunction
143
162
144
163
" Current Spec File Name
145
164
function ! InSpecFile ()
146
- return match (expand (" %" ),' \v(.js|.coffee|_spec.rb|.feature)$' ) != -1
165
+ return match (expand (" %" ),' \v(.tsx|.ts|. js|.coffee|_spec.rb|.feature)$' ) != -1
147
166
endfunction
148
167
149
168
" Cache Last Spec Command
@@ -152,8 +171,8 @@ function! SetLastSpecCommand(spec)
152
171
endfunction
153
172
154
173
" Spec Runner
155
- function ! RunSpecs (spec)
156
- call s: GetCorrectCommand ()
174
+ function ! RunSpecs (spec, debug )
175
+ call s: GetCorrectCommand (a: debug )
157
176
if g: spec_command == ? " "
158
177
echom " No spec command specified."
159
178
else
0 commit comments