-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(sbb-image): lit migration (#2029)
- Loading branch information
1 parent
b00745a
commit 8d915b8
Showing
4 changed files
with
132 additions
and
126 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './sbb-image'; |
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,39 +1,38 @@ | ||
import { aTimeout, assert, expect, fixture } from '@open-wc/testing'; | ||
import { html } from 'lit/static-html.js'; | ||
import { SbbImage } from './sbb-image'; | ||
import images from '../../global/images'; | ||
import { E2EElement, E2EPage, newE2EPage } from '@stencil/core/testing'; | ||
|
||
describe('sbb-image', () => { | ||
let element: E2EElement, page: E2EPage; | ||
let element: SbbImage; | ||
|
||
it('renders', async () => { | ||
const url = images[0]; | ||
element = await fixture(html`<sbb-image image-src="${url}"></sbb-image>`); | ||
|
||
page = await newE2EPage(); | ||
await page.setContent(`<sbb-image image-src="${url}"></sbb-image>`); | ||
element = await page.find('sbb-image'); | ||
expect(element).toHaveClass('hydrated'); | ||
|
||
await page.waitForChanges(); | ||
assert.instanceOf(element, SbbImage); | ||
await element.updateComplete; | ||
// Wait five seconds in hope the image will successfully be loaded | ||
// TODO: Find more reliable solution | ||
await new Promise((res) => setTimeout(res, 5000)); | ||
await page.waitForChanges(); | ||
await aTimeout(2000); | ||
await element.updateComplete; | ||
|
||
expect(element).dom.to.be.equal(` | ||
<sbb-image image-src="${url}"></sbb-image> | ||
`); | ||
|
||
expect(element).toEqualHtml(` | ||
<sbb-image image-src="${url}" class="hydrated"> | ||
<mock:shadow-root> | ||
<figure class="image__figure image__figure--loaded image__figure--ratio-16-9"> | ||
<div class="image__wrapper"> | ||
<img alt="" class="image__blur-hash" decoding="auto" height="562" loading="eager" src="${url}?blur=100&w=100&h=56" width="1000"> | ||
<picture> | ||
<source media="(min-width: 64rem)" sizes="1200px" srcset="${url}?auto=format%2Ccompress%2Ccs%3Dtinysrgb&w=1200&h=675&q=45 1200w, ${url}?auto=format%2Ccompress%2Ccs%3Dtinysrgb&w=2400&h=1350&q=20 2400w"> | ||
<source media="(min-width: 37.5rem)" sizes="976px" srcset="${url}?auto=format%2Ccompress%2Ccs%3Dtinysrgb&w=976&h=549&q=45 976w, ${url}?auto=format%2Ccompress%2Ccs%3Dtinysrgb&w=1952&h=1098&q=20 1952w"> | ||
<source media="(max-width: 37.4375rem)" sizes="320px" srcset="${url}?auto=format%2Ccompress%2Ccs%3Dtinysrgb&w=320&h=180&q=45 320w, ${url}?auto=format%2Ccompress%2Ccs%3Dtinysrgb&w=640&h=360&q=20 640w"> | ||
<img class="image__img" decoding="auto" height="562" importance="high" loading="eager" src="${url}" width="1000"> | ||
</picture> | ||
</div> | ||
</figure> | ||
</mock:shadow-root> | ||
</sbb-image> | ||
`); | ||
expect(element).shadowDom.to.be.equal(` | ||
<figure class="image__figure image__figure--loaded image__figure--ratio-16-9"> | ||
<div class="image__wrapper"> | ||
<img alt="" class="image__blur-hash" decoding="auto" height="562" loading="eager" src="${url}?blur=100&w=100&h=56" width="1000"> | ||
<picture> | ||
<source media="(min-width: 64rem)" sizes="1200px" srcset="${url}?auto=format%2Ccompress%2Ccs%3Dtinysrgb&w=1200&h=675&q=45 1200w, ${url}?auto=format%2Ccompress%2Ccs%3Dtinysrgb&w=2400&h=1350&q=20 2400w"> | ||
<source media="(min-width: 37.5rem)" sizes="976px" srcset="${url}?auto=format%2Ccompress%2Ccs%3Dtinysrgb&w=976&h=549&q=45 976w, ${url}?auto=format%2Ccompress%2Ccs%3Dtinysrgb&w=1952&h=1098&q=20 1952w"> | ||
<source media="(max-width: 37.4375rem)" sizes="320px" srcset="${url}?auto=format%2Ccompress%2Ccs%3Dtinysrgb&w=320&h=180&q=45 320w, ${url}?auto=format%2Ccompress%2Ccs%3Dtinysrgb&w=640&h=360&q=20 640w"> | ||
<img class="image__img" decoding="auto" height="562" importance="high" loading="eager" src="${url}" width="1000"> | ||
</picture> | ||
</div> | ||
</figure> | ||
`); | ||
}); | ||
}); |
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.