Skip to content

Commit 07849a2

Browse files
committed
update test
1 parent 5a7298c commit 07849a2

File tree

2 files changed

+18
-32
lines changed

2 files changed

+18
-32
lines changed
Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
{
2-
"code": "<script lang=\"ts\">
1+
<script lang="ts">
32
import manual_image1 from './no.png';
43
import manual_image2 from './no.svg';
54
@@ -13,54 +12,41 @@
1312

1413
{foo}
1514

16-
<img src=\"./foo.png\" alt=\"non-enhanced test\" />
15+
<img src="./foo.png" alt="non-enhanced test" />
1716

18-
<picture><source srcset=\"/1 1440w, /2 960w\" type=\"image/avif\" /><source srcset=\"/3 1440w, /4 960w\" type=\"image/webp\" /><source srcset=\"5 1440w, /6 960w\" type=\"image/png\" /><img src=/7 alt=\"basic test\" width=1440 height=1440 /></picture>
17+
<picture><source srcset="/1 1440w, /2 960w" sizes="min(1440px, 100vw)" type="image/avif" /><source srcset="/3 1440w, /4 960w" sizes="min(1440px, 100vw)" type="image/webp" /><source srcset="5 1440w, /6 960w" sizes="min(1440px, 100vw)" type="image/png" /><img src=/7 alt="basic test" width=1440 height=1440 /></picture>
1918

20-
<picture><source srcset=\"/1 1440w, /2 960w\" type=\"image/avif\" /><source srcset=\"/3 1440w, /4 960w\" type=\"image/webp\" /><source srcset=\"5 1440w, /6 960w\" type=\"image/png\" /><img src=/7 width=\"5\" height=\"10\" alt=\"dimensions test\" /></picture>
19+
<picture><source srcset="/1 1440w, /2 960w" sizes="min(1440px, 100vw)" type="image/avif" /><source srcset="/3 1440w, /4 960w" sizes="min(1440px, 100vw)" type="image/webp" /><source srcset="5 1440w, /6 960w" sizes="min(1440px, 100vw)" type="image/png" /><img src=/7 width="5" height="10" alt="dimensions test" /></picture>
2120

22-
<picture><source srcset=\"/1 1440w, /2 960w\" type=\"image/avif\" /><source srcset=\"/3 1440w, /4 960w\" type=\"image/webp\" /><source srcset=\"5 1440w, /6 960w\" type=\"image/png\" /><img src=/7 width=5 height=10 alt=\"unquoted dimensions test\" /></picture>
21+
<picture><source srcset="/1 1440w, /2 960w" sizes="min(1440px, 100vw)" type="image/avif" /><source srcset="/3 1440w, /4 960w" sizes="min(1440px, 100vw)" type="image/webp" /><source srcset="5 1440w, /6 960w" sizes="min(1440px, 100vw)" type="image/png" /><img src=/7 width=5 height=10 alt="unquoted dimensions test" /></picture>
2322

24-
<picture><source srcset=\"/1 1440w, /2 960w\" type=\"image/avif\" /><source srcset=\"/3 1440w, /4 960w\" type=\"image/webp\" /><source srcset=\"5 1440w, /6 960w\" type=\"image/png\" /><img src=/7 alt=\"directive test\" width=1440 height=1440 /></picture>
23+
<picture><source srcset="/1 1440w, /2 960w" sizes="min(1440px, 100vw)" type="image/avif" /><source srcset="/3 1440w, /4 960w" sizes="min(1440px, 100vw)" type="image/webp" /><source srcset="5 1440w, /6 960w" sizes="min(1440px, 100vw)" type="image/png" /><img src=/7 alt="directive test" width=1440 height=1440 /></picture>
2524

26-
<picture><source srcset=\"/1 1440w, /2 960w\" type=\"image/avif\" /><source srcset=\"/3 1440w, /4 960w\" type=\"image/webp\" /><source srcset=\"5 1440w, /6 960w\" type=\"image/png\" /><img src=/7 {...{foo}} alt=\"spread attributes test\" width=1440 height=1440 /></picture>
25+
<picture><source srcset="/1 1440w, /2 960w" sizes="min(1440px, 100vw)" type="image/avif" /><source srcset="/3 1440w, /4 960w" sizes="min(1440px, 100vw)" type="image/webp" /><source srcset="5 1440w, /6 960w" sizes="min(1440px, 100vw)" type="image/png" /><img src=/7 {...{foo}} alt="spread attributes test" width=1440 height=1440 /></picture>
2726

28-
<picture><source srcset=\"/1 1440w, /2 960w\" sizes=\"(min-width: 60rem) 80vw, (min-width: 40rem) 90vw, 100vw\" type=\"image/avif\" /><source srcset=\"/3 1440w, /4 960w\" sizes=\"(min-width: 60rem) 80vw, (min-width: 40rem) 90vw, 100vw\" type=\"image/webp\" /><source srcset=\"5 1440w, /6 960w\" sizes=\"(min-width: 60rem) 80vw, (min-width: 40rem) 90vw, 100vw\" type=\"image/png\" /><img src=/7 alt=\"sizes test\" width=1440 height=1440 /></picture>
27+
<picture><source srcset="/1 1440w, /2 960w" sizes="(min-width: 60rem) 80vw, (min-width: 40rem) 90vw, 100vw" type="image/avif" /><source srcset="/3 1440w, /4 960w" sizes="(min-width: 60rem) 80vw, (min-width: 40rem) 90vw, 100vw" type="image/webp" /><source srcset="5 1440w, /6 960w" sizes="(min-width: 60rem) 80vw, (min-width: 40rem) 90vw, 100vw" type="image/png" /><img src=/7 alt="sizes test" width=1440 height=1440 /></picture>
2928

30-
<picture><source srcset=\"/1 1440w, /2 960w\" type=\"image/avif\" /><source srcset=\"/3 1440w, /4 960w\" type=\"image/webp\" /><source srcset=\"5 1440w, /6 960w\" type=\"image/png\" /><img src=/7 on:click={foo = 'clicked an image!'} alt=\"event handler test\" width=1440 height=1440 /></picture>
29+
<picture><source srcset="/1 1440w, /2 960w" sizes="min(1440px, 100vw)" type="image/avif" /><source srcset="/3 1440w, /4 960w" sizes="min(1440px, 100vw)" type="image/webp" /><source srcset="5 1440w, /6 960w" sizes="min(1440px, 100vw)" type="image/png" /><img src=/7 on:click={foo = 'clicked an image!'} alt="event handler test" width=1440 height=1440 /></picture>
3130

32-
<picture><source srcset=\"/1 1440w, /2 960w\" type=\"image/avif\" /><source srcset=\"/3 1440w, /4 960w\" type=\"image/webp\" /><source srcset=\"5 1440w, /6 960w\" type=\"image/png\" /><img src=/7 alt=\"alias test\" width=1440 height=1440 /></picture>
31+
<picture><source srcset="/1 1440w, /2 960w" sizes="min(1440px, 100vw)" type="image/avif" /><source srcset="/3 1440w, /4 960w" sizes="min(1440px, 100vw)" type="image/webp" /><source srcset="5 1440w, /6 960w" sizes="min(1440px, 100vw)" type="image/png" /><img src=/7 alt="alias test" width=1440 height=1440 /></picture>
3332

34-
<picture><source srcset=\"/1 1440w, /2 960w\" type=\"image/avif\" /><source srcset=\"/3 1440w, /4 960w\" type=\"image/webp\" /><source srcset=\"5 1440w, /6 960w\" type=\"image/png\" /><img src=/7 alt=\"absolute path test\" width=1440 height=1440 /></picture>
33+
<picture><source srcset="/1 1440w, /2 960w" sizes="min(1440px, 100vw)" type="image/avif" /><source srcset="/3 1440w, /4 960w" sizes="min(1440px, 100vw)" type="image/webp" /><source srcset="5 1440w, /6 960w" sizes="min(1440px, 100vw)" type="image/png" /><img src=/7 alt="absolute path test" width=1440 height=1440 /></picture>
3534

3635
{#each images as image}
3736
{#if typeof image === 'string'}
38-
<img src={image.img.src} alt=\"opt-in test\" width={image.img.w} height={image.img.h} />
37+
<img src={image.img.src} alt="opt-in test" width={image.img.w} height={image.img.h} />
3938
{:else}
4039
<picture>
4140
{#each Object.entries(image.sources) as [format, srcset]}
42-
<source {srcset} type={'image/' + format} />
41+
<source {srcset} sizes="min({image.img.w}px, 100vw)" type={'image/' + format} />
4342
{/each}
44-
<img src={image.img.src} alt=\"opt-in test\" width={image.img.w} height={image.img.h} />
43+
<img src={image.img.src} alt="opt-in test" width={image.img.w} height={image.img.h} />
4544
</picture>
4645
{/if}
4746
{/each}
4847

4948
<picture>
50-
<source src=\"./foo.avif\" />
51-
<source srcset=\"./foo.avif 500v ./bar.avif 100v\" />
52-
<source srcset=\"./foo.avif, ./bar.avif 1v\" />
49+
<source src="./foo.avif" />
50+
<source srcset="./foo.avif 500v ./bar.avif 100v" />
51+
<source srcset="./foo.avif, ./bar.avif 1v" />
5352
</picture>
54-
",
55-
"dependencies": [],
56-
"map": SourceMap {
57-
"mappings": "",
58-
"names": [],
59-
"sourceRoot": undefined,
60-
"sources": [
61-
"Input.svelte",
62-
],
63-
"version": 3,
64-
},
65-
"toString": [Function],
66-
}

packages/enhanced-img/test/preprocessor.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ it('Image preprocess snapshot test', async () => {
2929
{ filename }
3030
);
3131

32-
expect(processed).toMatchFileSnapshot('./Output.svelte');
32+
expect(processed.code).toMatchFileSnapshot('./Output.svelte');
3333
});
3434

3535
it('parses a minimized object', () => {

0 commit comments

Comments
 (0)