1
1
import { describe , expect , it } from 'bun:test' ;
2
- import { appendBasePathToLinker , createLinker } from './links' ;
2
+ import { createLinker } from './links' ;
3
3
4
4
const root = createLinker ( {
5
5
host : 'docs.company.com' ,
6
- pathname : '/' ,
6
+ spaceBasePath : '/' ,
7
+ siteBasePath : '/' ,
7
8
} ) ;
8
9
9
10
const variantInSection = createLinker ( {
10
11
host : 'docs.company.com' ,
11
- pathname : '/section/variant' ,
12
+ spaceBasePath : '/section/variant' ,
13
+ siteBasePath : '/' ,
14
+ } ) ;
15
+
16
+ const siteGitBookIO = createLinker ( {
17
+ host : 'org.gitbook.io' ,
18
+ spaceBasePath : '/sitename/variant/' ,
19
+ siteBasePath : '/sitename/' ,
12
20
} ) ;
13
21
14
22
describe ( 'toPathInContent' , ( ) => {
@@ -23,6 +31,13 @@ describe('toPathInContent', () => {
23
31
} ) ;
24
32
} ) ;
25
33
34
+ describe ( 'toPathInSite' , ( ) => {
35
+ it ( 'should return the correct path' , ( ) => {
36
+ expect ( root . toPathInSite ( 'some/path' ) ) . toBe ( '/some/path' ) ;
37
+ expect ( siteGitBookIO . toPathInSite ( 'some/path' ) ) . toBe ( '/sitename/some/path' ) ;
38
+ } ) ;
39
+ } ) ;
40
+
26
41
describe ( 'toAbsoluteURL' , ( ) => {
27
42
it ( 'should return the correct path' , ( ) => {
28
43
expect ( root . toAbsoluteURL ( 'some/path' ) ) . toBe ( 'https://docs.company.com/some/path' ) ;
@@ -31,28 +46,3 @@ describe('toAbsoluteURL', () => {
31
46
) ;
32
47
} ) ;
33
48
} ) ;
34
-
35
- describe ( 'appendBasePathToLinker' , ( ) => {
36
- const prefixedRoot = appendBasePathToLinker ( root , '/section/variant' ) ;
37
- const prefixedVariantInSection = appendBasePathToLinker ( variantInSection , '/base' ) ;
38
-
39
- describe ( 'toPathInContent' , ( ) => {
40
- it ( 'should return the correct path' , ( ) => {
41
- expect ( prefixedRoot . toPathInSpace ( 'some/path' ) ) . toBe ( '/section/variant/some/path' ) ;
42
- expect ( prefixedVariantInSection . toPathInSpace ( 'some/path' ) ) . toBe (
43
- '/section/variant/base/some/path'
44
- ) ;
45
- } ) ;
46
- } ) ;
47
-
48
- describe ( 'toAbsoluteURL' , ( ) => {
49
- it ( 'should return the correct path' , ( ) => {
50
- expect ( prefixedRoot . toAbsoluteURL ( 'some/path' ) ) . toBe (
51
- 'https://docs.company.com/some/path'
52
- ) ;
53
- expect ( prefixedVariantInSection . toAbsoluteURL ( 'some/path' ) ) . toBe (
54
- 'https://docs.company.com/some/path'
55
- ) ;
56
- } ) ;
57
- } ) ;
58
- } ) ;
0 commit comments