-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(openApp): Allow the ability to provide virtual files.
BREAKING CHANGE: openApp() now takes an object as argument
- Loading branch information
1 parent
e88a86c
commit f95eb1a
Showing
7 changed files
with
299 additions
and
194 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,14 +1,44 @@ | ||
import test from 'ava' | ||
import {useTemporaryDirectory} from 'ava-patterns' | ||
import {closeTab, findElement} from 'puppet-strings' | ||
import openApp, {logger} from './index.js' | ||
|
||
test('compiling and opening a web application', async (t) => { | ||
const directory = await useTemporaryDirectory(t) | ||
await directory.writeFile( | ||
'component.js', | ||
` | ||
import { html } from 'htm/react' | ||
export default function() { | ||
return html\`<span>Hello World!</span>\` | ||
} | ||
`, | ||
) | ||
|
||
logger.on('log', (_, message) => t.log(message)) | ||
const app = await openApp({ | ||
path: directory.path, | ||
files: { | ||
'index.html': ` | ||
<!doctype html> | ||
<script type="module" src="/index.js"></script> | ||
<div></div> | ||
`, | ||
'index.js': ` | ||
import { createRoot } from 'react-dom/client' | ||
import { html } from 'htm/react' | ||
import Component from './component.js' | ||
const app = await openApp('./fixtures') | ||
const root = await findElement(app, '#root') | ||
const root = createRoot(document.body.firstElementChild) | ||
root.render(html\`<\${Component} />\`) | ||
`, | ||
}, | ||
}) | ||
t.teardown(async () => { | ||
await closeTab(app) | ||
}) | ||
|
||
const root = await findElement(app, 'div') | ||
t.is(root.textContent, 'Hello World!') | ||
|
||
await closeTab(app) | ||
}) |
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
Oops, something went wrong.