Here is my property declaration:
properties: {
size: {
type: String,
value: ''
},
sizeName: {
type: String,
value: ''
}
}
My CSS:
<style>
:root {
--width: 20px;
--height: 20px;
--border-color: black;
--font-size: 16px;
}
:host {
display: inline-block;
box-sizing: border-box;
height: var(--height);
width: var(--width);
}
#icon {
position: relative;
display: block;
width: var(--width);
height: var(--height);
border-radius: 50%;
border: 1px solid var(--border-color);
font-size: var(--font-size);
@apply(--size-icon);
}
#icon:before {
position: absolute;
top: 50%;
transform: translateY(-50%);
width: 100%;
content: '?';
text-align: center;
@apply(--size-icon--before);
}
#icon.small:before {content: 's';}
#icon.medium:before {content: 'm';}
#icon.large:before {content: 'l';}
#name {
font-size: var(--font-size);
@apply(--size-name);
}
.hidden {
display: none;
}
</style>
I have a test fixture as follows:
<test-fixture id="hasWrongSize">
<template>
<size-icon size="asdf"></size-icon>
</template>
<template>
<size-icon size=""></size-icon>
</template>
</test-fixture>
With a test suite as follows:
suite('when no icon size or incorrect icon size is provided', function() {
var el;
setup(function() {
el = fixture('hasWrongSize');
});
test('when the "size" property is incorrect the inner html equals "?"', function(done) {
flush(function() {
var domEl = Polymer.dom(el.root).querySelector('#icon:before');
expect(domEl.innerHTML).to.equal('?');
done();
});
});
});
The Local DOM of the custom element is as follows:
<template>
<template is="dom-if" if="{{ !sizeName }}">
<span id="icon" class$="{{size}}"></span>
</template>
<span id="name">{{ sizeName }}</span>
</template>
I am trying to get the :before
pseudo-element with the ID of #icon
but WCT isn't able to find it and domEl
in the test suite is equating to null
.
What am I doing wrong?