Files
Talks/tests/site-base.test.mjs
T
Le Prévost-Corvellec Arnault 354c8cd9ef Add Makefile, package.json, and initial configuration for VitePress and Slidev integration
- Introduced a Makefile for streamlined commands related to building, running, and managing presentations.
- Created package.json to define project metadata, dependencies, and scripts for development and testing.
- Added .gitignore entries to exclude build artifacts and temporary files from version control.
- Included playwright.config.mjs for end-to-end testing setup with Playwright.
- Added README.md for project documentation, outlining setup instructions and development guidelines.
2026-04-11 15:59:20 +02:00

47 lines
1.6 KiB
JavaScript

import { test, describe, beforeEach } from 'node:test'
import assert from 'node:assert'
import { getSiteBase, sitePath, vitepressAppBase } from '../tools/site-base.mjs'
describe('site-base (SITE_BASE / chemins statiques)', () => {
beforeEach(() => {
delete process.env.SITE_BASE
delete process.env.TALKS_PORTAL_DEV
})
test('défaut : même comportement que la racine du site', () => {
assert.strictEqual(getSiteBase(), '')
assert.strictEqual(sitePath('/slides/foo/'), '/slides/foo/')
assert.strictEqual(sitePath('/presentations/bar/'), '/presentations/bar/')
})
test('sous-chemin sans slash final', () => {
process.env.SITE_BASE = '/mon-depot'
assert.strictEqual(getSiteBase(), '/mon-depot')
assert.strictEqual(sitePath('/slides/foo/'), '/mon-depot/slides/foo/')
})
test('sous-chemin avec slash final', () => {
process.env.SITE_BASE = '/repo/'
assert.strictEqual(getSiteBase(), '/repo')
assert.strictEqual(sitePath('/slides/x/'), '/repo/slides/x/')
})
test('chemins relatifs normalisés', () => {
delete process.env.SITE_BASE
assert.strictEqual(sitePath('slides/x/'), '/slides/x/')
})
test('SITE_BASE vide explicite : traité comme /', () => {
process.env.SITE_BASE = ''
assert.strictEqual(getSiteBase(), '')
})
test('TALKS_PORTAL_DEV=1 : ignore SITE_BASE (dev local)', () => {
process.env.TALKS_PORTAL_DEV = '1'
process.env.SITE_BASE = '/pages-projet/'
assert.strictEqual(getSiteBase(), '')
assert.strictEqual(sitePath('/slides/a/'), '/slides/a/')
assert.strictEqual(vitepressAppBase(), '/')
})
})