Skip to content
Draft
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
1 change: 1 addition & 0 deletions __tests__/components/Accordion.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ describe('Accordion', () => {
);
const icon = container.querySelector('span.Accordion-icon');
expect(icon).toBeInTheDocument();
expect(icon).toHaveClass('Icon-emoji');
expect(icon).toHaveTextContent('馃殌');
});

Expand Down
1 change: 1 addition & 0 deletions __tests__/components/Callout.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ Body with **markdown** support.

const icon = container.querySelector('.callout-icon');
expect(icon?.tagName).toBe('SPAN');
expect(icon).toHaveClass('Icon-emoji');
expect(icon).toHaveTextContent('馃摌');
expect(icon).not.toHaveClass('callout-icon_fa');
});
Expand Down
11 changes: 11 additions & 0 deletions __tests__/components/Icon.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ import React from 'react';
import { expect } from 'vitest';

import Icon from '../../components/Icon';
import { Icon as ExportedIcon } from '../../index';

describe('Icon', () => {
it('is available as a direct public export without joining the component registry', () => {
expect(ExportedIcon).toBe(Icon);
});

describe('Font Awesome icons', () => {
it('renders an <i> for a bare fa- icon with the fa-duotone fa-solid fallback', () => {
const { container } = render(<Icon className="Test-icon" icon="fa-book" />);
Expand Down Expand Up @@ -53,9 +58,15 @@ describe('Icon', () => {
const { container } = render(<Icon className="Test-icon" icon="馃殌" />);
const icon = container.querySelector('span.Test-icon');
expect(icon).toBeInTheDocument();
expect(icon).toHaveClass('Icon-emoji');
expect(icon).toHaveTextContent('馃殌');
});

it('renders an emoji without requiring a caller class', () => {
const { container } = render(<Icon icon="馃殌" />);
expect(container.querySelector('span.Icon-emoji')).toHaveTextContent('馃殌');
});

it('does not render an <i> for an emoji', () => {
const { container } = render(<Icon className="Test-icon" icon="馃殌" />);
expect(container.querySelector('i.Test-icon')).toBeNull();
Expand Down
4 changes: 2 additions & 2 deletions __tests__/components/__snapshots__/Accordion.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ exports[`Accordion > mdx > renders an accordion with an emoji icon 1`] = `
class="Accordion-toggleIcon fa fa-regular fa-chevron-right"
/>
<span
class="Accordion-icon"
class="Accordion-icon Icon-emoji"
>
馃殌
</span>
Expand Down Expand Up @@ -119,7 +119,7 @@ exports[`Accordion > mdxish > renders an accordion with an emoji icon 1`] = `
class="Accordion-toggleIcon fa fa-regular fa-chevron-right"
/>
<span
class="Accordion-icon"
class="Accordion-icon Icon-emoji"
>
馃殌
</span>
Expand Down
8 changes: 4 additions & 4 deletions __tests__/components/__snapshots__/Callout.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports[`Callout > mdx: renders a callout with icon and body 1`] = `
theme="馃摌"
>
<span
class="callout-icon"
class="callout-icon Icon-emoji"
>
馃摌
</span>
Expand All @@ -25,7 +25,7 @@ exports[`Callout > mdx: renders the markdown inside the callout body 1`] = `
theme="馃摌"
>
<span
class="callout-icon"
class="callout-icon Icon-emoji"
>
馃摌
</span>
Expand Down Expand Up @@ -73,7 +73,7 @@ exports[`Callout > mdxish: renders a callout with icon and body 1`] = `
theme="馃摌"
>
<span
class="callout-icon"
class="callout-icon Icon-emoji"
>
馃摌
</span>
Expand All @@ -91,7 +91,7 @@ exports[`Callout > mdxish: renders the markdown inside the callout body 1`] = `
theme="馃摌"
>
<span
class="callout-icon"
class="callout-icon Icon-emoji"
>
馃摌
</span>
Expand Down
2 changes: 1 addition & 1 deletion __tests__/components/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`Components > Callout 1`] = `"<blockquote class="callout callout_error" theme="鉂楋笍"><span class="callout-icon">鉂楋笍</span><h3 class="heading heading-3 header-scroll"><div class="heading-anchor anchor waypoint" id="error-callout"></div><div class="heading-text">Error Callout</div><a aria-label="Skip link to Error Callout" class="heading-anchor-icon fa fa-regular fa-anchor" href="#error-callout"></a></h3><p>Lorem ipsum dolor.</p></blockquote>"`;
exports[`Components > Callout 1`] = `"<blockquote class="callout callout_error" theme="鉂楋笍"><span class="callout-icon Icon-emoji">鉂楋笍</span><h3 class="heading heading-3 header-scroll"><div class="heading-anchor anchor waypoint" id="error-callout"></div><div class="heading-text">Error Callout</div><a aria-label="Skip link to Error Callout" class="heading-anchor-icon fa fa-regular fa-anchor" href="#error-callout"></a></h3><p>Lorem ipsum dolor.</p></blockquote>"`;

exports[`Components > Embed 1`] = `"<div class="embed embed_hasImg"><div class="embed-media"><iframe class="embedly-embed" src="//cdn.embedly.com/widgets/media.html?src=https://www.google.com/maps/embed/v1/place?center=37.829698%2C-122.258166&amp;key=AIzaSyD9HrlRuI1Ani0-MTZ7pvzxwxi4pgW0BCY&amp;zoom=16&amp;q=4126+Opal+St,+Oakland,+CA+94609&amp;display_name=Google+Maps&amp;url=https://www.google.com/maps/place/4126+Opal+St,+Oakland,+CA+94609/@37.829698,-122.258166,16z/data=!4m5!3m4!1s0x80857dfb145a04ff:0x96b17d967421636f!8m2!3d37.8296978!4d-122.2581661?hl=en&amp;image=http://maps-api-ssl.google.com/maps/api/staticmap?center=37.829698,-122.258166&amp;zoom=15&amp;size=250x250&amp;sensor=false&amp;key=02466f963b9b4bb8845a05b53d3235d7&amp;type=text/html&amp;schema=google" width="600" height="450" scrolling="no" title="Google Maps embed" frameborder="0" allow="autoplay; fullscreen" allowfullscreen="true"></iframe></div></div>"`;

Expand Down
2 changes: 1 addition & 1 deletion __tests__/components/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('Components', () => {
({ container } = render(React.createElement(component)));

expect(container.innerHTML).toMatchInlineSnapshot(
'"<blockquote class="callout callout_warn" theme="馃毀"><span class="callout-icon">馃毀</span><p class="callout-heading empty"></p><p>Callout with no title.</p></blockquote>"',
'"<blockquote class="callout callout_warn" theme="馃毀"><span class="callout-icon Icon-emoji">馃毀</span><p class="callout-heading empty"></p><p>Callout with no title.</p></blockquote>"',
);

cleanup();
Expand Down
Loading