Skip to content

Commit

Permalink
yo
Browse files Browse the repository at this point in the history
  • Loading branch information
Zizzamia committed Feb 2, 2024
1 parent 677a3a5 commit 0d2edfe
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions src/components/FrameMetadata.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ describe('FrameMetadata', () => {

it('renders with image', () => {
const meta = render(<FrameMetadata image="https://example.com/image.png" />);
expect(meta.container.querySelector('meta[property="fc:frame:image"]')).not.toBeNull();
expect(
meta.container.querySelector('meta[property="fc:frame:image"]')?.getAttribute('content'),
).toBe('https://example.com/image.png');
expect(meta.container.querySelectorAll('meta').length).toBe(2);
});

it('renders with input', () => {
const meta = render(<FrameMetadata image="https://example.com/image.png" input={{ text: 'test' }} />);
const meta = render(
<FrameMetadata image="https://example.com/image.png" input={{ text: 'test' }} />,
);
expect(meta.container.querySelector('meta[property="fc:frame:input:text"]')).not.toBeNull();
expect(
meta.container.querySelector('meta[property="fc:frame:input:text"]')?.getAttribute('content'),
Expand All @@ -32,10 +33,7 @@ describe('FrameMetadata', () => {
const meta = render(
<FrameMetadata
image="https://example.com/image.png"
buttons={[
{ label: 'button1' },
{ label: 'button2', action: 'post_redirect' },
]}
buttons={[{ label: 'button1' }, { label: 'button2', action: 'post_redirect' }]}
/>,
);
// Button 1
Expand All @@ -49,16 +47,22 @@ describe('FrameMetadata', () => {
expect(
meta.container.querySelector('meta[property="fc:frame:button:2"]')?.getAttribute('content'),
).toBe('button2');
expect(meta.container.querySelector('meta[property="fc:frame:button:2:action"]')).not.toBeNull();
expect(
meta.container.querySelector('meta[property="fc:frame:button:2:action"]')?.getAttribute('content'),
meta.container.querySelector('meta[property="fc:frame:button:2:action"]'),
).not.toBeNull();
expect(
meta.container
.querySelector('meta[property="fc:frame:button:2:action"]')
?.getAttribute('content'),
).toBe('post_redirect');
// Length
expect(meta.container.querySelectorAll('meta').length).toBe(5);
});

it('renders with post_url', () => {
const meta = render(<FrameMetadata image="https://example.com/image.png" post_url="https://example.com" />);
const meta = render(
<FrameMetadata image="https://example.com/image.png" post_url="https://example.com" />,
);
expect(meta.container.querySelector('meta[property="fc:frame:post_url"]')).not.toBeNull();
expect(
meta.container.querySelector('meta[property="fc:frame:post_url"]')?.getAttribute('content'),
Expand All @@ -67,10 +71,14 @@ describe('FrameMetadata', () => {
});

it('renders with refresh_period', () => {
const meta = render(<FrameMetadata image="https://example.com/image.png" refresh_period={10} />);
const meta = render(
<FrameMetadata image="https://example.com/image.png" refresh_period={10} />,
);
expect(meta.container.querySelector('meta[property="fc:frame:refresh_period"]')).not.toBeNull();
expect(
meta.container.querySelector('meta[property="fc:frame:refresh_period"]')?.getAttribute('content'),
meta.container
.querySelector('meta[property="fc:frame:refresh_period"]')
?.getAttribute('content'),
).toBe('10');
expect(meta.container.querySelectorAll('meta').length).toBe(3);
});
Expand Down

0 comments on commit 0d2edfe

Please sign in to comment.