@@ -489,6 +489,69 @@ describe('<Script /> component', () => {
489
489
'<html><head><script type="module" src="/static/client-abc.js"></script></head><body><main><honox-island component-name="/mocks/app-script/islands/Component.tsx" data-serialized-props="{}"><p>Component</p></honox-island></main></body></html>'
490
490
)
491
491
} )
492
+
493
+ describe ( 'with base path - root relative' , ( ) => {
494
+ const originalBaseURL = import . meta. env . BASE_URL
495
+
496
+ beforeAll ( ( ) => {
497
+ // this means `base: "/base/path/"` in vite.config.ts
498
+ import . meta. env . BASE_URL = '/base/path/'
499
+ } )
500
+
501
+ afterAll ( ( ) => {
502
+ import . meta. env . BASE_URL = originalBaseURL
503
+ } )
504
+
505
+ it ( 'Should convert the script path correctly' , async ( ) => {
506
+ const res = await app . request ( '/' )
507
+ expect ( res . status ) . toBe ( 200 )
508
+ expect ( await res . text ( ) ) . toBe (
509
+ '<html><head><script type="module" src="/base/path/static/client-abc.js"></script></head><body><main><honox-island component-name="/mocks/app-script/islands/Component.tsx" data-serialized-props="{}"><p>Component</p></honox-island></main></body></html>'
510
+ )
511
+ } )
512
+ } )
513
+
514
+ describe ( 'with base path - root relative, without trailing slash' , ( ) => {
515
+ const originalBaseURL = import . meta. env . BASE_URL
516
+
517
+ beforeAll ( ( ) => {
518
+ // this means `base: "/base/path"` in vite.config.ts
519
+ import . meta. env . BASE_URL = '/base/path'
520
+ } )
521
+
522
+ afterAll ( ( ) => {
523
+ import . meta. env . BASE_URL = originalBaseURL
524
+ } )
525
+
526
+ it ( 'Should convert the script path correctly' , async ( ) => {
527
+ const res = await app . request ( '/' )
528
+ expect ( res . status ) . toBe ( 200 )
529
+ expect ( await res . text ( ) ) . toBe (
530
+ '<html><head><script type="module" src="/base/path/static/client-abc.js"></script></head><body><main><honox-island component-name="/mocks/app-script/islands/Component.tsx" data-serialized-props="{}"><p>Component</p></honox-island></main></body></html>'
531
+ )
532
+ } )
533
+ } )
534
+
535
+ describe ( 'with base path - absolute url' , ( ) => {
536
+ const originalBaseURL = import . meta. env . BASE_URL
537
+
538
+ beforeAll ( ( ) => {
539
+ // this means `base: "https://example.com/base/path/"` in vite.config.ts
540
+ import . meta. env . BASE_URL = 'https://example.com/base/path/'
541
+ } )
542
+
543
+ afterAll ( ( ) => {
544
+ import . meta. env . BASE_URL = originalBaseURL
545
+ } )
546
+
547
+ it ( 'Should convert the script path correctly' , async ( ) => {
548
+ const res = await app . request ( '/' )
549
+ expect ( res . status ) . toBe ( 200 )
550
+ expect ( await res . text ( ) ) . toBe (
551
+ '<html><head><script type="module" src="https://example.com/base/path/static/client-abc.js"></script></head><body><main><honox-island component-name="/mocks/app-script/islands/Component.tsx" data-serialized-props="{}"><p>Component</p></honox-island></main></body></html>'
552
+ )
553
+ } )
554
+ } )
492
555
} )
493
556
494
557
describe ( 'With async' , ( ) => {
@@ -555,6 +618,69 @@ describe('<Link /> component', () => {
555
618
'<html><head><link href="/static/globals-abc.css" rel="stylesheet"></link></head><body><main><div></div></main></body></html>'
556
619
)
557
620
} )
621
+
622
+ describe ( 'with base path - root relative' , ( ) => {
623
+ const originalBaseURL = import . meta. env . BASE_URL
624
+
625
+ beforeAll ( ( ) => {
626
+ // this means `base: "/base/path/"` in vite.config.ts
627
+ import . meta. env . BASE_URL = '/base/path/'
628
+ } )
629
+
630
+ afterAll ( ( ) => {
631
+ import . meta. env . BASE_URL = originalBaseURL
632
+ } )
633
+
634
+ it ( 'Should convert the link path correctly' , async ( ) => {
635
+ const res = await app . request ( '/' )
636
+ expect ( res . status ) . toBe ( 200 )
637
+ expect ( await res . text ( ) ) . toBe (
638
+ '<html><head><link href="/base/path/static/globals-abc.css" rel="stylesheet"></link></head><body><main><div></div></main></body></html>'
639
+ )
640
+ } )
641
+ } )
642
+
643
+ describe ( 'with base path - root relative, without trailing slash' , ( ) => {
644
+ const originalBaseURL = import . meta. env . BASE_URL
645
+
646
+ beforeAll ( ( ) => {
647
+ // this means `base: "/base/path"` in vite.config.ts
648
+ import . meta. env . BASE_URL = '/base/path'
649
+ } )
650
+
651
+ afterAll ( ( ) => {
652
+ import . meta. env . BASE_URL = originalBaseURL
653
+ } )
654
+
655
+ it ( 'Should convert the link path correctly' , async ( ) => {
656
+ const res = await app . request ( '/' )
657
+ expect ( res . status ) . toBe ( 200 )
658
+ expect ( await res . text ( ) ) . toBe (
659
+ '<html><head><link href="/base/path/static/globals-abc.css" rel="stylesheet"></link></head><body><main><div></div></main></body></html>'
660
+ )
661
+ } )
662
+ } )
663
+
664
+ describe ( 'with base path - absolute url' , ( ) => {
665
+ const originalBaseURL = import . meta. env . BASE_URL
666
+
667
+ beforeAll ( ( ) => {
668
+ // this means `base: "https://example.com/base/path/"` in vite.config.ts
669
+ import . meta. env . BASE_URL = 'https://example.com/base/path/'
670
+ } )
671
+
672
+ afterAll ( ( ) => {
673
+ import . meta. env . BASE_URL = originalBaseURL
674
+ } )
675
+
676
+ it ( 'Should convert the link path correctly' , async ( ) => {
677
+ const res = await app . request ( '/' )
678
+ expect ( res . status ) . toBe ( 200 )
679
+ expect ( await res . text ( ) ) . toBe (
680
+ '<html><head><link href="https://example.com/base/path/static/globals-abc.css" rel="stylesheet"></link></head><body><main><div></div></main></body></html>'
681
+ )
682
+ } )
683
+ } )
558
684
} )
559
685
} )
560
686
0 commit comments