|
1 | | -import type { ResolvedFontOptions, SlideInfo } from '@slidev/types' |
| 1 | +import type { ResolvedFontOptions, SlideInfo, SlideRoute } from '@slidev/types' |
2 | 2 | import { relative, resolve } from 'node:path' |
3 | 3 | import { slash } from '@antfu/utils' |
| 4 | +import { getSlidePath } from '@slidev/client/logic/slides' |
4 | 5 | import MarkdownIt from 'markdown-it' |
5 | 6 | import { describe, expect, it } from 'vitest' |
6 | 7 | import YAML from 'yaml' |
@@ -145,4 +146,28 @@ describe('utils', () => { |
145 | 146 | " |
146 | 147 | `) |
147 | 148 | }) |
| 149 | + |
| 150 | + it('getSlidePath with base path', () => { |
| 151 | + const originalBaseUrl = import.meta.env.BASE_URL |
| 152 | + |
| 153 | + import.meta.env.BASE_URL = '/my_monorepo/my_prez/' |
| 154 | + |
| 155 | + const mockRoute: SlideRoute = { |
| 156 | + no: 2, |
| 157 | + meta: { |
| 158 | + slide: { |
| 159 | + frontmatter: {}, |
| 160 | + }, |
| 161 | + }, |
| 162 | + } |
| 163 | + |
| 164 | + expect(getSlidePath(mockRoute, false, false)).toBe('/my_monorepo/my_prez/2') |
| 165 | + expect(getSlidePath(mockRoute, true, false)).toBe('/my_monorepo/my_prez/presenter/2') |
| 166 | + expect(getSlidePath(mockRoute, false, true)).toBe('/my_monorepo/my_prez/export/2') |
| 167 | + |
| 168 | + import.meta.env.BASE_URL = '/' |
| 169 | + expect(getSlidePath(mockRoute, false, false)).toBe('/2') |
| 170 | + |
| 171 | + import.meta.env.BASE_URL = originalBaseUrl |
| 172 | + }) |
148 | 173 | }) |
0 commit comments