Skip to content

Commit

Permalink
Add test for global config
Browse files Browse the repository at this point in the history
  • Loading branch information
zerodevx committed Aug 30, 2024
1 parent cf430a5 commit 88027c2
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/fixtures/config.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Test</title>
<script type="module">
import ZeroMd from '../lib/index.js'
customElements.define(
'zero-md',
class extends ZeroMd {
async load() {
await super.load()
this.setAttribute('no-shadow', '')
this.setAttribute('no-auto', '')
this.setAttribute('body-class', 'test')
this.src = 'basic.md'
}
}
)
</script>
</head>
<body>
<zero-md></zero-md>
</body>
</html>
22 changes: 22 additions & 0 deletions src/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,25 @@ test.describe('feature tests', () => {
).toHaveClass('markdown-alert markdown-alert-note')
})
})

test.describe('global config', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/fixtures/config.html')
})

test('no-shadow', async ({ page }) => {
expect(await page.locator('zero-md').evaluate((el) => !!el.shadowRoot)).toBe(false)
})

test('no-auto', async ({ page }) => {
expect(await page.locator('.markdown-body').textContent()).toBe('')
})

test('body-class', async ({ page }) => {
await expect(page.locator('.markdown-body')).toHaveClass('markdown-body test')
})

test('src', async ({ page }) => {
await expect(page.locator('zero-md')).toHaveAttribute('src', 'basic.md')
})
})

0 comments on commit 88027c2

Please sign in to comment.