Skip to content

Commit

Permalink
add test for callouts
Browse files Browse the repository at this point in the history
  • Loading branch information
eransakal authored and aegatlin committed Jan 13, 2023
1 parent 663eb82 commit 3d6453e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/Test File.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@ And a very good one, too!
```elixir
d = 3
```

> [!tip] Tip
> this is a callout section of type tip with a header
> [!info] this is a callout section of type info without a header
17 changes: 17 additions & 0 deletions tests/getMark.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import assert from 'assert/strict'
import { describe, it } from 'node:test'
import { Metamark } from '../dist/index.js'
import { escapeRegExp } from './utils.js'

describe('Metamark.getMark', () => {
it('works with defaults', () => {
Expand All @@ -26,5 +27,21 @@ describe('Metamark.getMark', () => {
actual.text,
/This is a Wiki Link./g
)

// callouts
assert.match(
actual.html,
new RegExp(escapeRegExp(`<blockquote class="callout" style="border-left-color:#00bfa6;">
<div class="callout-title tip" style="background-color: #00bfa61a;"><span style="color:#00bfa6" class="callout-icon"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide-flame"><path d="M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z"></path></svg></span><strong><p>Tip</p></strong></div>
<div class="callout-content" style=""><p>this is a callout section of type tip with a header</p></div>
</blockquote>`, 'g'))
)

assert.match(
actual.html,
new RegExp(escapeRegExp(`<blockquote class="callout" style="border-left-color:#00b8d4;">
<div class="callout-title info" style="background-color: #00b8d41a;"><span style="color:#00b8d4" class="callout-icon"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide-info"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="16" x2="12" y2="12"></line><line x1="12" y1="8" x2="12.01" y2="8"></line></svg></span><strong><p>this is a callout section of type info without a header</p></strong></div>
</blockquote>`, 'g'))
)
})
})
3 changes: 3 additions & 0 deletions tests/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function escapeRegExp(string) {
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
}

0 comments on commit 3d6453e

Please sign in to comment.