Skip to content

Instantly share code, notes, and snippets.

@mraerino
Last active January 18, 2018 13:23
Show Gist options
  • Save mraerino/fce691640d4798454dc485ae559f6bb4 to your computer and use it in GitHub Desktop.
Save mraerino/fce691640d4798454dc485ae559f6bb4 to your computer and use it in GitHub Desktop.
Testing Fit-Html components using Web-Component-Tester
suite('ShadowRoot', function() {
test('ShadowRoot exists', function() {
const Component = FitHtml.connect(
() => console.log('state props called'),
{},
() => FitHtml.html``
);
customElements.define('test-has-shadow-root', Component);
litHtml.render(litHtml.html`
<test-has-shadow-root id="test"></test-has-shadow-root>
`, testFixture);
assert.isNotNull(document.getElementById('test').shadowRoot);
});
});
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script src="../node_modules/web-component-tester/browser.js"></script>
<script src="../dist/bundled/index.js"></script>
</head>
<body>
<store-provider>
<div id="fixture"></div>
</store-provider>
<script type="module">
import * as LitHtml from '../node_modules/lit-html/lit-html.js';
window.litHtml = LitHtml;
window.testFixture = document.getElementById('fixture');
customElements.define('store-provider', FitHtml.createProvider({
subscribe: () => {},
getState: () => {}
}));
WCT.loadSuites([
'has-shadow-root.js',
]);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment