| 
1 | 1 | import { expect } from '@bundled-es-modules/chai';  | 
2 | 2 | import { getAssetUrl, setAssetsBaseUrl } from '../src/lib/assets-url.js';  | 
 | 3 | +import { getDevHubUrl, getDocUrl, setDevHubBaseUrl } from '../src/lib/dev-hub-url.js';  | 
3 | 4 | 
 
  | 
4 | 5 | describe('assets-url module', () => {  | 
5 | 6 |   describe('getAssetUrl function', () => {  | 
@@ -72,3 +73,76 @@ describe('assets-url module', () => {  | 
72 | 73 |     });  | 
73 | 74 |   });  | 
74 | 75 | });  | 
 | 76 | + | 
 | 77 | +describe('dev-hub-url module', () => {  | 
 | 78 | +  describe('getDocUrl', () => {  | 
 | 79 | +    it('should append /doc/ and path to base URL without trailing slash', () => {  | 
 | 80 | +      expect(getDocUrl('foo/bar')).to.equal('https://www.clever.cloud/developers/doc/foo/bar');  | 
 | 81 | +    });  | 
 | 82 | + | 
 | 83 | +    it('should handle path with leading slash', () => {  | 
 | 84 | +      expect(getDocUrl('/foo/bar')).to.equal('https://www.clever.cloud/developers/doc/foo/bar');  | 
 | 85 | +    });  | 
 | 86 | + | 
 | 87 | +    it('should handle empty path', () => {  | 
 | 88 | +      expect(getDocUrl()).to.equal('https://www.clever.cloud/developers/doc');  | 
 | 89 | +    });  | 
 | 90 | +  });  | 
 | 91 | + | 
 | 92 | +  describe('getDevHubUrl', () => {  | 
 | 93 | +    it('should append path to base URL without trailing slash', () => {  | 
 | 94 | +      expect(getDevHubUrl('foo/bar')).to.equal('https://www.clever.cloud/developers/foo/bar');  | 
 | 95 | +    });  | 
 | 96 | + | 
 | 97 | +    it('should handle path with leading slash', () => {  | 
 | 98 | +      expect(getDevHubUrl('/foo/bar')).to.equal('https://www.clever.cloud/developers/foo/bar');  | 
 | 99 | +    });  | 
 | 100 | + | 
 | 101 | +    it('should handle empty path', () => {  | 
 | 102 | +      expect(getDevHubUrl()).to.equal('https://www.clever.cloud/developers');  | 
 | 103 | +    });  | 
 | 104 | +  });  | 
 | 105 | + | 
 | 106 | +  describe('setDevHubBaseUrl', () => {  | 
 | 107 | +    const originalUrl = 'https://www.clever.cloud/developers';  | 
 | 108 | + | 
 | 109 | +    afterEach(() => {  | 
 | 110 | +      setDevHubBaseUrl(originalUrl);  | 
 | 111 | +    });  | 
 | 112 | + | 
 | 113 | +    it('should set custom base URL without trailing slash', () => {  | 
 | 114 | +      setDevHubBaseUrl('https://custom-dev-hub.example.com');  | 
 | 115 | +      expect(getDevHubUrl('foo/bar')).to.equal('https://custom-dev-hub.example.com/foo/bar');  | 
 | 116 | +    });  | 
 | 117 | + | 
 | 118 | +    it('should set custom base URL with trailing slash', () => {  | 
 | 119 | +      setDevHubBaseUrl('https://custom-dev-hub.example.com/');  | 
 | 120 | +      expect(getDevHubUrl('foo/bar')).to.equal('https://custom-dev-hub.example.com/foo/bar');  | 
 | 121 | +    });  | 
 | 122 | + | 
 | 123 | +    it('should affect getDocUrl', () => {  | 
 | 124 | +      setDevHubBaseUrl('https://custom-dev-hub.example.com');  | 
 | 125 | +      expect(getDocUrl('foo/bar')).to.equal('https://custom-dev-hub.example.com/doc/foo/bar');  | 
 | 126 | +    });  | 
 | 127 | + | 
 | 128 | +    it('should work with localhost URL', () => {  | 
 | 129 | +      setDevHubBaseUrl('http://localhost:8080');  | 
 | 130 | +      expect(getDevHubUrl('foo/bar')).to.equal('http://localhost:8080/foo/bar');  | 
 | 131 | +      expect(getDocUrl('foo/bar')).to.equal('http://localhost:8080/doc/foo/bar');  | 
 | 132 | +    });  | 
 | 133 | + | 
 | 134 | +    it('should work with relative path base URL', () => {  | 
 | 135 | +      setDevHubBaseUrl('/local/dev-hub');  | 
 | 136 | +      expect(getDevHubUrl('foo/bar')).to.equal('/local/dev-hub/foo/bar');  | 
 | 137 | +      expect(getDocUrl('foo/bar')).to.equal('/local/dev-hub/doc/foo/bar');  | 
 | 138 | +    });  | 
 | 139 | + | 
 | 140 | +    it('should reset to new URL after multiple calls', () => {  | 
 | 141 | +      setDevHubBaseUrl('https://first-hub.example.com');  | 
 | 142 | +      expect(getDevHubUrl('test')).to.equal('https://first-hub.example.com/test');  | 
 | 143 | + | 
 | 144 | +      setDevHubBaseUrl('https://second-hub.example.com/');  | 
 | 145 | +      expect(getDevHubUrl('test')).to.equal('https://second-hub.example.com/test');  | 
 | 146 | +    });  | 
 | 147 | +  });  | 
 | 148 | +});  | 
0 commit comments