Skip to content

Commit

Permalink
Add test for prerendered link in <YouTube>
Browse files Browse the repository at this point in the history
  • Loading branch information
delucis committed Mar 30, 2024
1 parent 4228a30 commit 7e0750e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
1 change: 0 additions & 1 deletion tests/astro-embed-twitter.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-check
import { test } from 'uvu';
import { renderScreen } from './utils/render.mjs';

Expand Down
1 change: 0 additions & 1 deletion tests/astro-embed-vimeo.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-check
import { test } from 'uvu';
import * as assert from 'uvu/assert';
import { renderDOM } from './utils/render.mjs';
Expand Down
7 changes: 6 additions & 1 deletion tests/astro-embed-youtube.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-check
import { test } from 'uvu';
import * as assert from 'uvu/assert';
import { renderDOM } from './utils/render.mjs';
Expand All @@ -16,6 +15,12 @@ test('it should render a lite-youtube element', async () => {
embed.style['background-image'],
`url('https://i.ytimg.com/vi_webp/${videoid}/hqdefault.webp')`
);
// It renders a static link to the video.
const playButton = /** @type {HTMLAnchorElement} */ (
embed.querySelector('a.lty-playbtn')
);
assert.ok(playButton);
assert.is(playButton.href, `https://youtube.com/watch?v=${videoid}`);
});

test('it parses a youtube.com URL', async () => {
Expand Down
1 change: 0 additions & 1 deletion tests/utils/render.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-check
/* eslint-disable no-console */
import { prettyDOM, queries } from '@testing-library/dom';
import { getComponentOutput } from 'astro-component-tester';
Expand Down
6 changes: 5 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"extends": "astro/tsconfigs/strictest"
"extends": "astro/tsconfigs/strictest",
"compilerOptions": {
"allowJs": true,
"checkJs": true
}
}

0 comments on commit 7e0750e

Please sign in to comment.