@@ -161,3 +161,126 @@ describe("check layout", function()
161
161
assert .is_true (result )
162
162
end )
163
163
end )
164
+
165
+ describe (" layout.has_tmux_target" , function ()
166
+ local layout
167
+ local tmux
168
+
169
+ setup (function ()
170
+ require (" spec.tmux.mocks.log_mock" ).setup ()
171
+ require (" spec.tmux.mocks.tmux_mock" ).setup (" 3.2a" )
172
+
173
+ layout = require (" tmux.layout" )
174
+ tmux = require (" tmux.wrapper.tmux" )
175
+ end )
176
+
177
+ it (" check is_tmux false" , function ()
178
+ tmux .is_tmux = false
179
+
180
+ local result = layout .has_tmux_target (" h" , false , true )
181
+ assert .is_false (result )
182
+
183
+ result = layout .has_tmux_target (" j" , false , true )
184
+ assert .is_false (result )
185
+
186
+ result = layout .has_tmux_target (" k" , false , true )
187
+ assert .is_false (result )
188
+
189
+ result = layout .has_tmux_target (" l" , false , true )
190
+ assert .is_false (result )
191
+ end )
192
+
193
+ it (" check is_zoomed true" , function ()
194
+ tmux .is_tmux = true
195
+ tmux .is_zoomed = function ()
196
+ return true
197
+ end
198
+ layout .is_border = function (_ )
199
+ return false
200
+ end
201
+
202
+ local result = layout .has_tmux_target (" h" , true , true )
203
+ assert .is_false (result )
204
+
205
+ result = layout .has_tmux_target (" j" , true , true )
206
+ assert .is_false (result )
207
+
208
+ result = layout .has_tmux_target (" k" , true , true )
209
+ assert .is_false (result )
210
+
211
+ result = layout .has_tmux_target (" l" , true , true )
212
+ assert .is_false (result )
213
+
214
+ result = layout .has_tmux_target (" h" , false , true )
215
+ assert .is_true (result )
216
+
217
+ result = layout .has_tmux_target (" j" , false , true )
218
+ assert .is_true (result )
219
+
220
+ result = layout .has_tmux_target (" k" , false , true )
221
+ assert .is_true (result )
222
+
223
+ result = layout .has_tmux_target (" l" , false , true )
224
+ assert .is_true (result )
225
+ end )
226
+
227
+ it (" check is_border false" , function ()
228
+ tmux .is_tmux = true
229
+ tmux .is_zoomed = function ()
230
+ return false
231
+ end
232
+ layout .is_border = function (_ )
233
+ return false
234
+ end
235
+
236
+ local result = layout .has_tmux_target (" h" , false , true )
237
+ assert .is_true (result )
238
+
239
+ result = layout .has_tmux_target (" j" , false , true )
240
+ assert .is_true (result )
241
+
242
+ result = layout .has_tmux_target (" k" , false , true )
243
+ assert .is_true (result )
244
+
245
+ result = layout .has_tmux_target (" l" , false , true )
246
+ assert .is_true (result )
247
+ end )
248
+
249
+ it (" check is_border true" , function ()
250
+ tmux .is_tmux = true
251
+ tmux .is_zoomed = function ()
252
+ return false
253
+ end
254
+ layout .is_border = function (_ )
255
+ return true
256
+ end
257
+
258
+ local result = layout .has_tmux_target (" h" , false , false )
259
+ assert .is_false (result )
260
+
261
+ result = layout .has_tmux_target (" j" , false , false )
262
+ assert .is_false (result )
263
+
264
+ result = layout .has_tmux_target (" k" , false , false )
265
+ assert .is_false (result )
266
+
267
+ result = layout .has_tmux_target (" l" , false , false )
268
+ assert .is_false (result )
269
+ end )
270
+
271
+ it (" check cycle_navigation true" , function ()
272
+ tmux .is_tmux = true
273
+ tmux .is_zoomed = function ()
274
+ return false
275
+ end
276
+ layout .is_border = function (direction )
277
+ return direction == " h"
278
+ end
279
+
280
+ local result = layout .has_tmux_target (" h" , false , false )
281
+ assert .is_false (result )
282
+
283
+ result = layout .has_tmux_target (" h" , false , true )
284
+ assert .is_true (result )
285
+ end )
286
+ end )
0 commit comments