Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add unit test for YoutubeEmbed component #6983

Merged
merged 2 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"scripts": {
"clean": "rm -rf node_modules yarn.lock",
"refresh": "yarn clean && yarn",
"test": "jest",
"test": "jest --coverage",
"dev": "yarn prebuild && next dev",
"spellcheck": "cspell \"src/**/*.mdx\" --no-progress",
"spellcheck-diff": "git diff --name-only --cached | awk \"/src.*\\.mdx/{print}\" | npx cspell --no-must-find-files --file-list stdin",
Expand Down
21 changes: 21 additions & 0 deletions src/components/YoutubeEmbed/__tests__/YoutubeEmbed.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as React from 'react';
import { render, screen } from '@testing-library/react';
import { YoutubeEmbed } from '../index';

describe('YoutubeEmbed', () => {
const embedId = 'uaG2mMYLI68';
const component = <YoutubeEmbed embedId={embedId} />;
it('should render the YoutubeEmbed component', async () => {
render(component);
const iframe = await screen.getByTitle('YouTube video player');
expect(iframe).toBeInTheDocument();
});

it('should be sized to 560w by 315h', async () => {
render(component);
const iframe = await screen.getByTitle('YouTube video player');
expect(iframe.getAttribute('style')).toEqual(
'--youtube-embed-width: 560; --youtube-embed-height: 315;'
);
});
});
Loading