|
| 1 | +import { describe, expect, it } from 'bun:test'; |
| 2 | +import { getVisitorAuthBasePath } from './visitor'; |
| 3 | + |
| 4 | +describe('getVisitorAuthBasePath', () => { |
| 5 | + it('should return the correct base path for proxy requests', () => { |
| 6 | + expect( |
| 7 | + getVisitorAuthBasePath( |
| 8 | + new URL('https://proxy.gitbook.site/sites/site_foo/hello/world'), |
| 9 | + { |
| 10 | + site: 'site_foo', |
| 11 | + siteSpace: 'sitesp_foo', |
| 12 | + basePath: '/foo', |
| 13 | + siteBasePath: '/foo', |
| 14 | + organization: 'org_foo', |
| 15 | + space: 'space_foo', |
| 16 | + pathname: '/hello/world', |
| 17 | + complete: false, |
| 18 | + apiToken: 'api_token_foo', |
| 19 | + canonicalUrl: 'https://example.com/docs/foo/hello/world', |
| 20 | + } |
| 21 | + ) |
| 22 | + ).toBe('/sites/site_foo/'); |
| 23 | + }); |
| 24 | + |
| 25 | + it('should return the correct base path for non-proxy requests', () => { |
| 26 | + expect( |
| 27 | + getVisitorAuthBasePath(new URL('https://example.com/docs/foo/hello/world'), { |
| 28 | + site: 'site_foo', |
| 29 | + siteSpace: 'sitesp_foo', |
| 30 | + basePath: '/foo/', |
| 31 | + siteBasePath: '/foo/', |
| 32 | + organization: 'org_foo', |
| 33 | + space: 'space_foo', |
| 34 | + pathname: '/hello/world', |
| 35 | + complete: false, |
| 36 | + apiToken: 'api_token_foo', |
| 37 | + canonicalUrl: 'https://example.com/docs/foo/hello/world', |
| 38 | + }) |
| 39 | + ).toBe('/foo/'); |
| 40 | + }); |
| 41 | +}); |
0 commit comments