-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* update:Change screen state to "Generate render function based on AST" * test:chapter's e2e tests ( 10_minimum_example/060_template_compiler2)
- Loading branch information
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
book/impls/10_minimum_example/060_template_compiler2/tests/e2e.spec.ts
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,57 @@ | ||
import { afterEach, beforeEach, describe, expect, it } from 'vitest' | ||
|
||
import { createApp } from '../packages' | ||
|
||
let host: HTMLElement | ||
const initHost = () => { | ||
host = document.createElement('div') | ||
host.setAttribute('id', 'host') | ||
document.body.appendChild(host) | ||
} | ||
beforeEach(() => initHost()) | ||
afterEach(() => host.remove()) | ||
|
||
describe('10_minimum_example/060_template_compiler', () => { | ||
it('should render template option', () => { | ||
const app = createApp({ | ||
template: ` | ||
<div class="container" style="text-align: center"> | ||
<h2>Hello, chibivue!</h2> | ||
<img | ||
width="150px" | ||
src="https://upload.wikimedia.org/wikipedia/commons/thumb/9/95/Vue.js_Logo_2.svg/1200px-Vue.js_Logo_2.svg.png" | ||
alt="Vue.js Logo" | ||
/> | ||
<p><b>chibivue</b> is the minimal Vue.js</p> | ||
<style> | ||
.container { | ||
height: 100vh; | ||
padding: 16px; | ||
background-color: #becdbe; | ||
color: #2c3e50; | ||
} | ||
</style> | ||
</div> | ||
`, | ||
}) | ||
app.mount('#host') | ||
|
||
expect(host.innerHTML).toBe( | ||
`<div class="container" style="text-align: center"> | ||
<h2>Hello, chibivue!</h2> | ||
<img width="150px" src="https://upload.wikimedia.org/wikipedia/commons/thumb/9/95/Vue.js_Logo_2.svg/1200px-Vue.js_Logo_2.svg.png" alt="Vue.js Logo"> | ||
<p><b>chibivue</b> is the minimal Vue.js</p> | ||
<style> | ||
.container { | ||
height: 100vh; | ||
padding: 16px; | ||
background-color: #becdbe; | ||
color: #2c3e50; | ||
} | ||
</style> | ||
</div>`, | ||
) | ||
}) | ||
}) |