Skip to content

Commit

Permalink
refactor: update link rendering in Zenn Markdown HTML tests
Browse files Browse the repository at this point in the history
This commit modifies the link rendering in the Zenn Markdown HTML tests. It replaces the usage of the 'span.zenn-embedded iframe' selector with 'aside iframe' to match the updated HTML structure. Additionally, it adds assertions to check that the rendered HTML contains the correct link format.

Co-authored-by: Ryosuke Igarashi <[email protected]>
  • Loading branch information
senkenn and cm-igarashi-ryosuke committed Aug 14, 2024
1 parent fc403a2 commit 3eb6851
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions packages/zenn-markdown-html/__tests__/link.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,32 @@ describe('Linkifyのテスト', () => {

test('<details />内のリンクはリンクカードに変換しない', () => {
const html = renderLink(':::message alert\nhttps://example.com\n:::');
const iframe = parse(html).querySelector('span.zenn-embedded iframe');
const iframe = parse(html).querySelector('aside iframe');
expect(iframe).toBeNull();
expect(html).toContain(
'<a href="https://example.com" target="_blank" rel="nofollow noopener noreferrer">https://example.com</a>'
);
});

test('<details />内の2段落空いたリンクをリンクカードに変換しない', () => {
const html = renderLink(
':::message alert\nhello\n\nhttps://example.com\n:::'
);
const iframes = parse(html).querySelectorAll('span.zenn-embedded iframe');
const iframes = parse(html).querySelectorAll('aside iframe');
expect(iframes.length).toBe(0);
console.log(html);
expect(html).toContain(
'<a href="https://example.com" target="_blank" rel="nofollow noopener noreferrer">https://example.com</a>'
);
});

test('リスト内のリンクをリンクカードに変換しない', () => {
const html = renderLink('- https://example.com\n- second');
const iframe = parse(html).querySelector('span.zenn-embedded iframe');
const iframe = parse(html).querySelector('aside iframe');
expect(iframe).toBeNull();
expect(html).toContain(
'<a href="https://example.com" target="_blank" rel="nofollow noopener noreferrer">https://example.com</a>'
);
});

test('URLにテキストが続く場合はリンクカードに変換しない', () => {
Expand Down

0 comments on commit 3eb6851

Please sign in to comment.