|
| 1 | +<?php |
| 2 | + |
| 3 | +require_once __DIR__.'/../helpers.php'; |
| 4 | + |
| 5 | +describe('buildSearchPathString', function () { |
| 6 | + it('wraps a single path in braces with glob wildcard', function () { |
| 7 | + $result = buildSearchPathString('/Projects', '/Users/test'); |
| 8 | + |
| 9 | + expect($result)->toBe('{/Projects}/*'); |
| 10 | + }); |
| 11 | + |
| 12 | + it('joins multiple comma-separated paths', function () { |
| 13 | + $result = buildSearchPathString('/Projects,/Work', '/Users/test'); |
| 14 | + |
| 15 | + expect($result)->toBe('{/Projects,/Work}/*'); |
| 16 | + }); |
| 17 | + |
| 18 | + it('expands tilde to home directory', function () { |
| 19 | + $result = buildSearchPathString('~/Projects', '/Users/test'); |
| 20 | + |
| 21 | + expect($result)->toBe('{/Users/test/Projects}/*'); |
| 22 | + }); |
| 23 | + |
| 24 | + it('expands tilde in multiple paths', function () { |
| 25 | + $result = buildSearchPathString('~/Projects,~/Work', '/Users/test'); |
| 26 | + |
| 27 | + expect($result)->toBe('{/Users/test/Projects,/Users/test/Work}/*'); |
| 28 | + }); |
| 29 | + |
| 30 | + it('handles mixed absolute and tilde paths', function () { |
| 31 | + $result = buildSearchPathString('~/Projects,/var/www', '/Users/test'); |
| 32 | + |
| 33 | + expect($result)->toBe('{/Users/test/Projects,/var/www}/*'); |
| 34 | + }); |
| 35 | + |
| 36 | + it('trims whitespace from paths', function () { |
| 37 | + $result = buildSearchPathString(' /Projects , /Work ', '/Users/test'); |
| 38 | + |
| 39 | + expect($result)->toBe('{/Projects,/Work}/*'); |
| 40 | + }); |
| 41 | + |
| 42 | + it('trims whitespace and expands tilde together', function () { |
| 43 | + $result = buildSearchPathString(' ~/Projects ', '/Users/test'); |
| 44 | + |
| 45 | + expect($result)->toBe('{/Users/test/Projects}/*'); |
| 46 | + }); |
| 47 | +}); |
0 commit comments