-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added support for <await/> tags
- Loading branch information
Showing
10 changed files
with
189 additions
and
16 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
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
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,11 @@ | ||
module.exports = { | ||
onCreate(input) { | ||
this.state = { | ||
hidden: input.hidden, | ||
}; | ||
}, | ||
|
||
changeInput() { | ||
this.state.hidden = true; | ||
}, | ||
}; |
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,15 @@ | ||
<div class="mock-component"> | ||
<await(res from input)> | ||
<h1>${res.title}</h1> | ||
|
||
<button type="button" key="button" on-click('changeInput')>Hello</button> | ||
|
||
<tbody-component attribute=input key="tbody" if(!state.hidden)> | ||
<@body> | ||
<await(none from {})> | ||
body is here | ||
</await> | ||
</@body> | ||
</tbody-component> | ||
</await> | ||
</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,4 @@ | ||
{ | ||
"title": "hello", | ||
"i": 0 | ||
} |
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,3 @@ | ||
{ | ||
"hidden": true | ||
} |
72 changes: 72 additions & 0 deletions
72
tests/components/withAwait/test/__snapshots__/index.spec.js.snap
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,72 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`should render component with default fixture 1`] = ` | ||
Array [ | ||
, | ||
<div | ||
class="mock-component" | ||
> | ||
<h1> | ||
hello | ||
</h1> | ||
<button | ||
type="button" | ||
> | ||
Hello | ||
</button> | ||
<tbody-component | ||
attribute="{\\"title\\":\\"hello\\",\\"i\\":0}" | ||
> | ||
<at_body> | ||
body is here | ||
</at_body> | ||
</tbody-component> | ||
</div>, | ||
, | ||
] | ||
`; | ||
|
||
exports[`should render component with hidden fixture 1`] = ` | ||
Array [ | ||
, | ||
<div | ||
class="mock-component" | ||
> | ||
<h1> | ||
</h1> | ||
<button | ||
type="button" | ||
> | ||
Hello | ||
</button> | ||
</div>, | ||
, | ||
] | ||
`; | ||
|
||
exports[`should render component with undefined fixture 1`] = ` | ||
Array [ | ||
, | ||
<div | ||
class="mock-component" | ||
> | ||
<h1> | ||
</h1> | ||
<button | ||
type="button" | ||
> | ||
Hello | ||
</button> | ||
<tbody-component | ||
attribute="{}" | ||
> | ||
<at_body> | ||
body is here | ||
</at_body> | ||
</tbody-component> | ||
</div>, | ||
, | ||
] | ||
`; |
Empty file.
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 @@ | ||
module.exports = undefined; |
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,17 @@ | ||
const { render, fixtures } = require('../../../../src/index')('../index.marko', { withAwait: true }); | ||
|
||
describe('When component is rendered', () => { | ||
let component; | ||
|
||
beforeEach(async () => { | ||
component = await render(fixtures.default); | ||
}); | ||
|
||
afterEach(() => { | ||
component.destroy(); | ||
}); | ||
|
||
it('should process await tags', () => { | ||
expect(component.getEl().querySelectorAll('await').length).toBe(0); | ||
}); | ||
}); |