mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-15 15:44:45 -04:00
feat: import markdown-it-plugins from https://github.com/hedgedoc/markdown-it-plugins
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
1d90013344
commit
f5736dad0f
37 changed files with 2025 additions and 0 deletions
56
markdown-it-plugins/src/image-size/index.test.ts
Normal file
56
markdown-it-plugins/src/image-size/index.test.ts
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
import MarkdownIt from 'markdown-it/lib'
|
||||
|
||||
import { imageSize } from './index.js'
|
||||
import { describe, expect, it } from '@jest/globals'
|
||||
|
||||
describe('markdown-it-imsize', function () {
|
||||
const md = new MarkdownIt({
|
||||
html: true,
|
||||
linkify: true,
|
||||
typographer: true
|
||||
}).use(imageSize)
|
||||
|
||||
it('renders a image without size or title', () => {
|
||||
expect(md.renderInline('')).toBe('<img src="x" alt="test">')
|
||||
})
|
||||
|
||||
it('renders a image with title', () => {
|
||||
expect(md.renderInline('')).toBe('<img src="x" alt="test" title="thisisthetitle">')
|
||||
})
|
||||
|
||||
it('renders an image with absolute width and height', () => {
|
||||
expect(md.renderInline('')).toBe('<img src="x" alt="test" width="100" height="200">')
|
||||
})
|
||||
|
||||
it('renders an image with relative width and height', () => {
|
||||
expect(md.renderInline('')).toBe('<img src="x" alt="test" width="100%" height="200%">')
|
||||
})
|
||||
|
||||
it('renders an image with title and size', () => {
|
||||
expect(md.renderInline('')).toBe(
|
||||
'<img src="x" alt="test" title="thisisthetitle" width="100" height="200">'
|
||||
)
|
||||
})
|
||||
|
||||
it('renders an image with no size but x', () => {
|
||||
expect(md.renderInline('')).toBe('<img src="x" alt="test" title="thisisthetitle">')
|
||||
})
|
||||
|
||||
it("doesn't render an image with invalid size syntax", () => {
|
||||
expect(md.renderInline('')).toBe('')
|
||||
})
|
||||
|
||||
it('renders an image with only width', () => {
|
||||
expect(md.renderInline('')).toBe('<img src="x" alt="test" width="100">')
|
||||
})
|
||||
|
||||
it('renders an image with only height', () => {
|
||||
expect(md.renderInline('')).toBe('<img src="x" alt="test" height="200">')
|
||||
})
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue