Skip to content

Commit cccb073

Browse files
authored
fix: allow hiding one html code block (#116)
1 parent 77a6f08 commit cccb073

File tree

4 files changed

+9201
-14113
lines changed

4 files changed

+9201
-14113
lines changed

cypress/integration/extract-fiddles.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
const { stripIndent } = require('common-tags')
55
import { extractFiddles } from '../../src/markdown-utils'
66

7-
chai.config.truncateThreshold = 1000
7+
chai.config.truncateThreshold = 1500
88

99
/** @type {string} */
1010
let fiddleCommentMarkdown
1111
/** @type {string} */
1212
let fiddleHtmlBlocksMarkdown
13+
/** @type {string} */
14+
let fiddleHideHtmlBlocksMarkdown
1315

1416
before(() => {
1517
cy.readFile('cypress/integration/fiddle-comment.md').then(
@@ -19,6 +21,10 @@ before(() => {
1921
cy.readFile('cypress/integration/multiple-html-blocks.md').then(
2022
(md) => (fiddleHtmlBlocksMarkdown = md),
2123
)
24+
25+
cy.readFile('cypress/integration/hide-html.md').then(
26+
(md) => (fiddleHideHtmlBlocksMarkdown = md),
27+
)
2228
})
2329

2430
describe('extractFiddles', () => {
@@ -190,4 +196,24 @@ describe('extractFiddles', () => {
190196
export: false,
191197
})
192198
})
199+
200+
it('hides html block', () => {
201+
const fiddles = extractFiddles(fiddleHideHtmlBlocksMarkdown)
202+
const fiddle = fiddles['Hide HTML block'][0]
203+
expect(fiddle).to.deep.equal({
204+
name: 'HTML source not shown',
205+
test: "cy.get('div#greeting').should('have.text', 'Hello')",
206+
html: [
207+
{
208+
source: '<div id="greeting">Hello</div>',
209+
hide: true,
210+
},
211+
],
212+
commonHtml: null,
213+
css: null,
214+
only: false,
215+
skip: false,
216+
export: false,
217+
})
218+
})
193219
})

cypress/integration/hide-html.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Hide HTML block
2+
3+
<!-- fiddle HTML source not shown -->
4+
5+
```html hide
6+
<div id="greeting">Hello</div>
7+
```
8+
9+
```js
10+
cy.get('div#greeting').should('have.text', 'Hello')
11+
```
12+
13+
<!-- fiddle-end -->

0 commit comments

Comments
 (0)