@@ -2,10 +2,12 @@ import { rewriteLinkPath } from "../rewrite-link-path"
2
2
3
3
beforeEach ( ( ) => {
4
4
global . __TRAILING_SLASH__ = ``
5
+ global . __PATH_PREFIX__ = undefined
5
6
} )
6
7
7
- const getRewriteLinkPath = ( option = `legacy` ) => {
8
+ const getRewriteLinkPath = ( option = `legacy` , pathPrefix = undefined ) => {
8
9
global . __TRAILING_SLASH__ = option
10
+ global . __PATH_PREFIX__ = pathPrefix
9
11
return rewriteLinkPath
10
12
}
11
13
@@ -20,6 +22,7 @@ describe(`rewriteLinkPath`, () => {
20
22
expect ( getRewriteLinkPath ( ) ( `/path?query_param=hello#anchor` , `/` ) ) . toBe (
21
23
`/path?query_param=hello#anchor`
22
24
)
25
+ expect ( getRewriteLinkPath ( `legacy` , `/prefix` ) ( `/` , `/` ) ) . toBe ( `/prefix/` )
23
26
} )
24
27
it ( `handles always option` , ( ) => {
25
28
expect ( getRewriteLinkPath ( `always` ) ( `/path` , `/` ) ) . toBe ( `/path/` )
@@ -31,6 +34,7 @@ describe(`rewriteLinkPath`, () => {
31
34
expect (
32
35
getRewriteLinkPath ( `always` ) ( `/path?query_param=hello#anchor` , `/` )
33
36
) . toBe ( `/path/?query_param=hello#anchor` )
37
+ expect ( getRewriteLinkPath ( `always` , `/prefix` ) ( `/` , `/` ) ) . toBe ( `/prefix/` )
34
38
} )
35
39
it ( `handles never option` , ( ) => {
36
40
expect ( getRewriteLinkPath ( `never` ) ( `/path` , `/` ) ) . toBe ( `/path` )
@@ -42,6 +46,7 @@ describe(`rewriteLinkPath`, () => {
42
46
expect (
43
47
getRewriteLinkPath ( `never` ) ( `/path/?query_param=hello#anchor` , `/` )
44
48
) . toBe ( `/path?query_param=hello#anchor` )
49
+ expect ( getRewriteLinkPath ( `never` , `/prefix` ) ( `/` , `/` ) ) . toBe ( `/prefix` )
45
50
} )
46
51
it ( `handles ignore option` , ( ) => {
47
52
expect ( getRewriteLinkPath ( `ignore` ) ( `/path` , `/` ) ) . toBe ( `/path` )
@@ -53,5 +58,6 @@ describe(`rewriteLinkPath`, () => {
53
58
expect (
54
59
getRewriteLinkPath ( `ignore` ) ( `/path?query_param=hello#anchor` , `/` )
55
60
) . toBe ( `/path?query_param=hello#anchor` )
61
+ expect ( getRewriteLinkPath ( `ignore` , `/prefix` ) ( `/` , `/` ) ) . toBe ( `/prefix/` )
56
62
} )
57
63
} )
0 commit comments