Skip to content

Commit

Permalink
chore: add unit test for YoutubeEmbed component (#6983)
Browse files Browse the repository at this point in the history
* chore: add unit test for YoutubeEmbed component

* add code coverage stats

---------

Co-authored-by: katiegoines <katiegoines@gmail.com>
  • Loading branch information
katiegoines and katiegoines committed Feb 29, 2024
1 parent 3647359 commit fb1b8ed
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
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;'
);
});
});

0 comments on commit fb1b8ed

Please sign in to comment.