|
1 | | -import {transformPath} from '../transformPath'; |
| 1 | +import {EPathType} from '../../../../types/api/schema'; |
| 2 | +import {isDomain, transformPath} from '../transformPath'; |
2 | 3 |
|
3 | 4 | describe('transformPath', () => { |
4 | 5 | test.each([ |
@@ -41,3 +42,32 @@ describe('transformPath', () => { |
41 | 42 | expect(transformPath('///dev/v1/sth', '/dev')).toBe('v1/sth'); |
42 | 43 | }); |
43 | 44 | }); |
| 45 | + |
| 46 | +describe('isDomain', () => { |
| 47 | + it('should return true for valid domain paths', () => { |
| 48 | + expect(isDomain('/domain', EPathType.EPathTypeDir)).toBe(true); |
| 49 | + expect(isDomain('/another-domain', EPathType.EPathTypeDir)).toBe(true); |
| 50 | + }); |
| 51 | + |
| 52 | + it('should return false for non-directory paths', () => { |
| 53 | + expect(isDomain('/domain', EPathType.EPathTypeColumnStore)).toBe(false); |
| 54 | + expect(isDomain('/domain', undefined)).toBe(false); |
| 55 | + }); |
| 56 | + |
| 57 | + it('should return false for paths without slash', () => { |
| 58 | + expect(isDomain('domain', EPathType.EPathTypeDir)).toBe(false); |
| 59 | + }); |
| 60 | + |
| 61 | + it('should return false for paths with multiple slashes', () => { |
| 62 | + expect(isDomain('/domain/subdomain', EPathType.EPathTypeDir)).toBe(false); |
| 63 | + expect(isDomain('/domain/', EPathType.EPathTypeDir)).toBe(false); |
| 64 | + }); |
| 65 | + |
| 66 | + it('should return false for empty paths', () => { |
| 67 | + expect(isDomain('', EPathType.EPathTypeDir)).toBe(false); |
| 68 | + }); |
| 69 | + |
| 70 | + it('should return true for root path', () => { |
| 71 | + expect(isDomain('/', EPathType.EPathTypeDir)).toBe(true); |
| 72 | + }); |
| 73 | +}); |
0 commit comments