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

ドクセル埋め込み対応 #509

Merged
merged 8 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,34 @@ import { describe, test, expect } from 'vitest';
import markdownToHtml from '../../../src/index';

describe('Docswell', () => {
test('should generate docswell html', () => {
const html = markdownToHtml(
'@[docswell](https://www.docswell.com/slide/LK7J5V/embed)'
);
expect(html).toContain(
'<span class="embed-block embed-docswell"><iframe src="https://www.docswell.com/slide/LK7J5V/embed" allowfullscreen="true" width="620" style="border:1px solid #ccc;display:block;margin:0px auto;padding:0px;aspect-ratio:620/349"></iframe></span>'
);
describe('Docswellの埋め込み用URLの場合', () => {
test('Docswellのiframeを返すこと', () => {
const html = markdownToHtml(
'@[docswell](https://www.docswell.com/slide/LK7J5V/embed)'
);
expect(html).toContain(
'<span class="embed-block embed-docswell"><iframe src="https://www.docswell.com/slide/LK7J5V/embed" allowfullscreen="true" width="620" style="border:1px solid #ccc;display:block;margin:0px auto;padding:0px;aspect-ratio:620/349"></iframe></span>'
);
});
});

test('should not generate docswell html with invalid url', () => {
const html = markdownToHtml(
'@[docswell](https://www.docswell.com/s/ku-suke/LK7J5V-hello-docswell)'
);
expect(html).toContain('Docswellのembed用のURLを指定してください');
describe('DocswellのスライドURLの場合', () => {
test('Docswellのiframeを返すこと', () => {
const html = markdownToHtml(
'@[docswell](https://www.docswell.com/slide/LK7J5V/embed)'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここがスライドのURLになっていないです。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ありがとうございます!直しました! 🙏

);
expect(html).toContain(
'<span class="embed-block embed-docswell"><iframe src="https://www.docswell.com/slide/LK7J5V/embed" allowfullscreen="true" width="620" style="border:1px solid #ccc;display:block;margin:0px auto;padding:0px;aspect-ratio:620/349"></iframe></span>'
);
});
});

describe('DocswellのURLが不正な場合', () => {
test('エラーメッセージを返すこと', () => {
const html = markdownToHtml(
'@[docswell](https://www.docswell.com/invalid)'
);
expect(html).toContain('DocswellのスライドURLが不正です');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,32 @@ import { isDocswellUrl } from '../../src/utils/url-matcher';
import { describe, test, expect } from 'vitest';

describe('isDocswellUrlのテスト', () => {
describe('Docswellの埋め込み用URLのとき', () => {
describe('Docswellの埋め込み用URLの場合', () => {
test('trueを返すこと', () => {
const docswellEmbedUrl = 'https://www.docswell.com/slide/LK7J5V/embed';
expect(isDocswellUrl(docswellEmbedUrl)).toBe(true);
});
});

describe('Docswellの他の画面のURLのとき', () => {
describe('DocswellのスライドURLの場合', () => {
test('trueを返すこと', () => {
const docswellSlideUrl =
'https://www.docswell.com/s/ku-suke/LK7J5V-hello-docswell';
expect(isDocswellUrl(docswellSlideUrl)).toBe(true);
});
});

describe('Docswellの他の画面のURLの場合', () => {
test('falseを返すこと', () => {
const docswellUrls = [
'https://www.docswell.com/',
'https://www.docswell.com/s/ku-suke/LK7J5V-hello-docswell',
];
const docswellUrls = ['https://www.docswell.com/'];

docswellUrls.forEach((url) => {
expect(isDocswellUrl(url)).toBe(false);
});
});
});

describe('他のサイトのURLのとき', () => {
describe('他のサイトのURLの場合', () => {
test('falseを返すこと', () => {
const otherSiteUrls = ['https://zenn.dev/', 'https://github.com/'];

Expand Down
Loading