Skip to content

Commit 0493cf3

Browse files
committed
Add test for profile feat
1 parent a6cfb64 commit 0493cf3

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed

src/routes/+page.svelte

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@ import Img, { FxReveal, FxParallax } from '$lib'
1111
import { version } from '$app/environment'
1212
import testSingle from './assets/640/01.jpg?w=80&h=80&format=jpg&as=run:0'
1313
import testFallback from './assets/640/01.jpg?h=80'
14+
import testProfile from './assets/640/01.jpg?as=run2'
1415
1516
const modules = import.meta.glob('./assets/640/*.jpg', {
1617
import: 'default',
1718
eager: true,
1819
query: { w: 640, h: 640, fit: 'cover', as: 'run' }
1920
})
20-
2121
const esc = (i) => i
22-
2322
const images = Object.entries(modules).map((i) => i[1])
2423
let selected = 0
2524
</script>
@@ -94,11 +93,11 @@ export default defineConfig({
9493
</p>
9594
</div>
9695

97-
<div class="mx-auto mb-16 h-[32rem] w-full max-w-[1920px] overflow-hidden">
98-
<div
99-
class="h-full w-full blur"
100-
style="background: url(data:image/webp;base64,{i1.img.lqip}) no-repeat center/cover"
101-
/>
96+
<div
97+
class="mx-auto mb-16 h-[32rem] w-full max-w-[1920px] overflow-hidden"
98+
style="background: url(data:image/webp;base64,{i1.img.lqip}) no-repeat center/cover"
99+
>
100+
<div class="h-full w-full backdrop-blur-[20px]" />
102101
</div>
103102

104103
<div class="prose mx-auto mb-8 px-4">
@@ -195,6 +194,9 @@ const images = Object.entries(modules).map((i) => i[1])
195194
<Img src={testSingle} alt="test" />
196195
</div>
197196
<div class="test-fallback hidden">{JSON.stringify(testFallback)}</div>
197+
<div class="test-profile hidden">
198+
<Img src={testProfile} alt="test" />
199+
</div>
198200
<!-- End tests -->
199201

200202
<footer
@@ -203,13 +205,3 @@ const images = Object.entries(modules).map((i) => i[1])
203205
<span class="icon-[mdi--email] mr-2 h-6 w-6" />
204206
<a class="link" href="mailto:[email protected]">[email protected]</a>
205207
</footer>
206-
207-
<style>
208-
.blur::after {
209-
content: '';
210-
position: absolute;
211-
inset: 0;
212-
backdrop-filter: blur(20px);
213-
pointer-events: none;
214-
}
215-
</style>

tests/test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ test('run with param uses runDefaultDirectives', async ({ page }) => {
3434
expect(await page.locator('.test-run-param source').count()).toBe(3)
3535
})
3636

37+
test('basic profile tests', async ({ page }) => {
38+
await page.goto('/')
39+
const img = async (attr) => await page.locator('.test-profile img').getAttribute(attr)
40+
expect(await img('height')).toBe('16')
41+
expect(await img('width')).toBe('32')
42+
expect(await img('style')).toBeDefined()
43+
expect(await page.locator('.test-profile source').count()).toBe(0)
44+
})
45+
3746
/*
3847
test('', async ({ page }) => {
3948
await page.goto('/')

vite.config.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,12 @@ import { defineConfig } from 'vite'
33
import { imagetools } from './src/lib/vite.js'
44

55
export default defineConfig({
6-
plugins: [sveltekit(), imagetools()]
6+
plugins: [
7+
sveltekit(),
8+
imagetools({
9+
profiles: {
10+
run2: new URLSearchParams('w=32&h=16&fit=cover&format=jpg')
11+
}
12+
})
13+
]
714
})

0 commit comments

Comments
 (0)