Skip to content

Commit

Permalink
Merge 3fc52e6 into 0777d09
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed May 16, 2024
2 parents 0777d09 + 3fc52e6 commit 2c2ee2c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
6 changes: 6 additions & 0 deletions e2e/docs/components/auto-link.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
<AutoLink :config="{ text: 'text2', link: 'https://example.com/test/' }" />
</div>

<div id="attrs">
<AutoLink class="class" :config="{ text: 'text1', link: '/', ariaLabel: 'label', icon: 'icon1' }" />
<AutoLink id="id" :config="{ text: 'text2', link: 'https://example.com/test/', unknown: 'value' }" />
<AutoLink download="example-test.png" :config="{ text: 'text3', link: 'https://example.com/test.png' }" />
</div>

<script setup lang="ts">
import { AutoLink } from 'vuepress/client'

Expand Down
29 changes: 29 additions & 0 deletions e2e/tests/components/auto-link.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,32 @@ test('should render config correctly', async ({ page }) => {
await expect(locator.nth(1)).toHaveAttribute('target', '_blank')
await expect(locator.nth(1)).toHaveAttribute('rel', 'noopener noreferrer')
})

test('should append attrs correctly', async ({ page }) => {
const locator = page.locator('.e2e-theme-content #attrs a')

await expect(locator.nth(0)).toHaveText('text1')
await expect(locator.nth(0)).toHaveAttribute('href', BASE)
await expect(locator.nth(0)).toHaveAttribute('aria-label', 'label')
await expect(locator.nth(0)).toHaveAttribute('class', /class/)
await expect(locator.nth(0)).not.toHaveAttribute('icon')

await expect(locator.nth(1)).toHaveText('text2')
await expect(locator.nth(1)).toHaveAttribute(
'href',
'https://example.com/test/',
)
await expect(locator.nth(1)).toHaveAttribute('target', '_blank')
await expect(locator.nth(1)).toHaveAttribute('rel', 'noopener noreferrer')
await expect(locator.nth(1)).toHaveAttribute('id', 'id')
await expect(locator.nth(1)).not.toHaveAttribute('unknown')

await expect(locator.nth(2)).toHaveText('text3')
await expect(locator.nth(2)).toHaveAttribute(
'href',
'https://example.com/test.png',
)
await expect(locator.nth(2)).toHaveAttribute('target', '_blank')
await expect(locator.nth(2)).toHaveAttribute('rel', 'noopener noreferrer')
await expect(locator.nth(2)).toHaveAttribute('download', 'example-test.png')
})
2 changes: 0 additions & 2 deletions packages/client/src/components/AutoLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ export interface AutoLinkConfig {
export const AutoLink = defineComponent({
name: 'AutoLink',

inheritAttrs: false,

props: {
config: {
type: Object as PropType<AutoLinkConfig>,
Expand Down

0 comments on commit 2c2ee2c

Please sign in to comment.