-
Notifications
You must be signed in to change notification settings - Fork 1
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
25259ef
commit 44a6154
Showing
4 changed files
with
34 additions
and
9 deletions.
There are no files selected for viewing
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,5 @@ | ||
<div class="nested-one"> | ||
<slot before></slot> | ||
<slot></slot> | ||
<slot after></slot> | ||
</div> |
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,5 @@ | ||
<div> | ||
<slot before></slot> | ||
<slot></slot> | ||
<slot after></slot> | ||
</div> |
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,24 @@ | ||
'use strict'; | ||
|
||
const test = require('ava'); | ||
const plugin = require('../src'); | ||
const posthtml = require('posthtml'); | ||
const clean = html => html.replace(/(\n|\t)/g, '').trim(); | ||
|
||
test('Must process all nested component to html', async t => { | ||
const actual = `<div><x-nested-one></x-nested-one></div>`; | ||
const expected = `<div><div class="nested-one"><div class="nested-two"><div class="nested-three">Nested works!</div></div></div></div>`; | ||
|
||
const html = await posthtml([plugin({root: './test/templates/components'})]).process(actual).then(result => clean(result.html)); | ||
|
||
t.is(html, expected); | ||
}); | ||
|
||
test('Must process all nested component with slots to html', async t => { | ||
const actual = `<div><x-nested-one-slot><x-nested-two-slot>nested-two content<slot before>nested-two before</slot><slot after>nested-two after</slot></x-nested-two-slot><slot before>nested-one before</slot><slot after>nested-one after</slot></x-nested-one-slot></div>`; | ||
const expected = `<div><div class="nested-one"> nested-one before <div> nested-two before nested-two content nested-two after</div> nested-one after</div></div>`; | ||
|
||
const html = await posthtml([plugin({root: './test/templates/components'})]).process(actual).then(result => clean(result.html)); | ||
|
||
t.is(html, expected); | ||
}); |
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