wc-catalogue / blaze-elements

Web Component Blaze Elements
https://wc-catalogue.github.io/blaze-elements/
MIT License
10 stars 4 forks source link

Should we test that element is slotted properly? #238

Open elmariofredo opened 7 years ago

elmariofredo commented 7 years ago

Current behavior Currently we don't test if element is properly slotted, so if someone will remove line test will still pass.

Expected behavior we should do at least basic slot testing specially for mutli slot components

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

Hotell commented 7 years ago

well yes and no ! :D

For these particular reason I just wished we had snapshot testing but YES we should definitely test projection because it's component API like props.

Hard question is how to test it because

in native browsers

template (shadow dom) of my-el

<div>
  <h1>What is love?</h1>
  <slot/>
</div>

usage:

<my-el><p>I'm Jony Bravo</p><p>Hello mama!</p></my-el>

result in DOM:

<my-el>
  #shadowRoot
    |- <div>
    |-- <h1>What is love?</h1>
    |-- refPointer to light dom ->  <p>I'm Jony Bravo</p><p>Hello mama!</p>
    |- </div>
  <p>I'm Jony Bravo</p><p>Hello mama!</p>
</my-el>

in non native browsers

template (shadow dom) of my-el

<div>
  <h1>What is love?</h1>
  <slot/>
</div>

usage:

<my-el><p>I'm Jony Bravo</p><p>Hello mama!</p></my-el>

result in DOM:

<my-el>
    |- <div>
    |-- <h1>What is love?</h1>
    |-- <p>I'm Jony Bravo</p><p>Hello mama!</p>
    |- </div> 
</my-el>

So in non native we can just query but what about native?

any suggestions?