-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fixes validation issues when using the Astro
base
option
- Loading branch information
Showing
8 changed files
with
99 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
packages/starlight-links-validator/tests/base-path.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { expect, test } from 'vitest' | ||
|
||
import { ValidationErrorType } from '../libs/validation' | ||
|
||
import { expectValidationErrorCount, expectValidationErrors, loadFixture } from './utils' | ||
|
||
test('should validate links when the `base` Astro option is set', async () => { | ||
expect.assertions(2) | ||
|
||
try { | ||
await loadFixture('base-path') | ||
} catch (error) { | ||
expectValidationErrorCount(error, 8, 1) | ||
|
||
expectValidationErrors(error, 'test/test/', [ | ||
['/guides/example', ValidationErrorType.InvalidLink], | ||
['/guides/example/', ValidationErrorType.InvalidLink], | ||
['/guides/example#description', ValidationErrorType.InvalidLink], | ||
['/guides/example/#description', ValidationErrorType.InvalidLink], | ||
['/unknown', ValidationErrorType.InvalidLink], | ||
['/unknown/', ValidationErrorType.InvalidLink], | ||
['/test/guides/example#unknown', ValidationErrorType.InvalidAnchor], | ||
['/test/guides/example/#unknown', ValidationErrorType.InvalidAnchor], | ||
]) | ||
} | ||
}) |
14 changes: 14 additions & 0 deletions
14
packages/starlight-links-validator/tests/fixtures/base-path/astro.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import starlight from '@astrojs/starlight' | ||
import { defineConfig } from 'astro/config' | ||
|
||
import starlightLinksValidator from '../..' | ||
|
||
export default defineConfig({ | ||
base: '/test', | ||
integrations: [ | ||
starlight({ | ||
plugins: [starlightLinksValidator()], | ||
title: 'Starlight Links Validator Tests - trailing always', | ||
}), | ||
], | ||
}) |
7 changes: 7 additions & 0 deletions
7
...ght-links-validator/tests/fixtures/base-path/src/content/docs/guides/example.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
title: Example | ||
--- | ||
|
||
## Description | ||
|
||
This is an example page. |
25 changes: 25 additions & 0 deletions
25
...ges/starlight-links-validator/tests/fixtures/base-path/src/content/docs/test.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
title: Test | ||
--- | ||
|
||
# Some links | ||
|
||
- [External link](https://starlight.astro.build/) | ||
|
||
- [Example page](/test/guides/example) | ||
- [Example page](/test/guides/example/) | ||
|
||
- [Example page with hash](/test/guides/example#description) | ||
- [Example page with hash](/test/guides/example/#description) | ||
|
||
- [Example page with missing base](/guides/example) | ||
- [Example page with missing base](/guides/example/) | ||
|
||
- [Example page with missing base and hash](/guides/example#description) | ||
- [Example page with missing base and hash](/guides/example/#description) | ||
|
||
- [Unknown page](/unknown) | ||
- [Unknown page](/unknown/) | ||
|
||
- [Example page with unknown hash](/test/guides/example#unknown) | ||
- [Example page with unknown hash](/test/guides/example/#unknown) |