-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6ed6868
commit 297f875
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
packages/zenn-markdown-html/__tests__/custom-syntax/embed/docswell.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
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( | ||
'<script async class="docswell-embed" src="https://www.docswell.com/assets/libs/docswell-embed/docswell-embed.min.js" data-src="https://www.docswell.com/slide/LK7J5V/embed" data-aspect="0.5625"></script><div class="docswell-link"></div>' | ||
); | ||
}); | ||
|
||
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('Doscwellのembed用のURLを指定してください'); | ||
}); | ||
}); |
34 changes: 34 additions & 0 deletions
34
packages/zenn-markdown-html/__tests__/matchers/isDocswellUrl.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { isDocswellUrl } from '../../src/utils/url-matcher'; | ||
import { describe, test, expect } from 'vitest'; | ||
|
||
describe('isDocswellUrlのテスト', () => { | ||
describe('Docswellの埋め込み用URLのとき', () => { | ||
test('trueを返すこと', () => { | ||
const docswellEmbedUrl = 'https://www.docswell.com/slide/LK7J5V/embed'; | ||
expect(isDocswellUrl(docswellEmbedUrl)).toBe(true); | ||
}); | ||
}); | ||
|
||
describe('Docswellの他の画面のURLのとき', () => { | ||
test('falseを返すこと', () => { | ||
const docswellUrls = [ | ||
'https://www.docswell.com/', | ||
'https://www.docswell.com/s/ku-suke/LK7J5V-hello-docswell', | ||
]; | ||
|
||
docswellUrls.forEach((url) => { | ||
expect(isDocswellUrl(url)).toBe(false); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('他のサイトのURLのとき', () => { | ||
test('falseを返すこと', () => { | ||
const otherSiteUrls = ['https://zenn.dev/', 'https://github.com/']; | ||
|
||
otherSiteUrls.forEach((url) => { | ||
expect(isDocswellUrl(url)).toBe(false); | ||
}); | ||
}); | ||
}); | ||
}); |