Skip to content

Commit

Permalink
Fix test in shady DOM
Browse files Browse the repository at this point in the history
  • Loading branch information
TimvdLippe committed Mar 16, 2018
1 parent acfef71 commit a586b72
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions test/unit/styling-scoped.html
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@
<style include="importing-double-shared-style double-shared-style"></style>
</template>
<script>
addEventListener('WebComponentsReady', () => {
HTMLImports.whenReady(() => {
class DoubleSharedStylingElement extends Polymer.Element {
static get is() { return 'double-shared-styling-element'; }
}
Expand Down Expand Up @@ -1056,9 +1056,22 @@
});

test('only includes style modules once', function() {
assert.equal(el.shadowRoot.querySelector('style').textContent, `.double-shared-style {
const style = el.shadowRoot.querySelector('style');

// We cant use the regular "does a sub-node have the correct style",
// because we are actually need to assert on the actual style content.
// In native shadow dom, the style element resides in the shadowRoot,
// but in shadyDOM it has moved to the head and the selector has been altered.
if (style) {
assert.equal(style.textContent, `.double-shared-style {
color: green;
}`, 'There should be only one class selector in this style element');
} else {
assert.equal(document.head.querySelector('[scope="double-shared-styling-element"]').textContent,
`.double-shared-style.double-shared-styling-element {
color: green;
}`);
}
});
});

Expand Down

0 comments on commit a586b72

Please sign in to comment.