Skip to content

Commit 04e156e

Browse files
authored
test: use getBg and getColor (#20205)
1 parent 1aae595 commit 04e156e

6 files changed

Lines changed: 6 additions & 24 deletions

File tree

playground/assets/__tests__/assets.spec.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -438,10 +438,7 @@ describe('svg fragments', () => {
438438
})
439439

440440
test('via css url()', async () => {
441-
const bg = await page.evaluate(() => {
442-
return getComputedStyle(document.querySelector('.icon')).backgroundImage
443-
})
444-
expect(bg).toMatch(/svg#icon-clock-view"\)$/)
441+
expect(await getBg('.icon')).toMatch(/svg#icon-clock-view"\)$/)
445442
})
446443

447444
test('from js import', async () => {

playground/assets/__tests__/encoded-base/assets-encoded-base.spec.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,7 @@ describe('svg fragments', () => {
163163
})
164164

165165
test('via css url()', async () => {
166-
const bg = await page.evaluate(
167-
() => getComputedStyle(document.querySelector('.icon')).backgroundImage,
168-
)
169-
expect(bg).toMatch(/svg#icon-clock-view"\)$/)
166+
expect(await getBg('.icon')).toMatch(/svg#icon-clock-view"\)$/)
170167
})
171168

172169
test('from js import', async () => {

playground/assets/__tests__/relative-base/assets-relative-base.spec.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,7 @@ describe('svg fragments', () => {
176176
})
177177

178178
test('via css url()', async () => {
179-
const bg = await page.evaluate(() => {
180-
return getComputedStyle(document.querySelector('.icon')).backgroundImage
181-
})
182-
expect(bg).toMatch(/svg#icon-clock-view"\)$/)
179+
expect(await getBg('.icon')).toMatch(/svg#icon-clock-view"\)$/)
183180
})
184181

185182
test('from js import', async () => {

playground/assets/__tests__/runtime-base/assets-runtime-base.spec.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,7 @@ describe('svg fragments', () => {
171171
})
172172

173173
test('via css url()', async () => {
174-
const bg = await page.evaluate(() => {
175-
return getComputedStyle(document.querySelector('.icon')).backgroundImage
176-
})
177-
expect(bg).toMatch(/svg#icon-clock-view"\)$/)
174+
expect(await getBg('.icon')).toMatch(/svg#icon-clock-view"\)$/)
178175
})
179176

180177
test('from js import', async () => {

playground/assets/__tests__/url-base/assets-url-base.spec.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,7 @@ describe('svg fragments', () => {
165165
})
166166

167167
test('via css url()', async () => {
168-
const bg = await page.evaluate(
169-
() => getComputedStyle(document.querySelector('.icon')).backgroundImage,
170-
)
171-
expect(bg).toMatch(/svg#icon-clock-view"\)$/)
168+
expect(await getBg('.icon')).toMatch(/svg#icon-clock-view"\)$/)
172169
})
173170

174171
test('from js import', async () => {

playground/dynamic-import/__tests__/dynamic-import.spec.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,7 @@ test('should load dynamic import with vars', async () => {
6262
// dynamic import css
6363
test('should load dynamic import with css', async () => {
6464
await page.click('.css')
65-
await untilUpdated(
66-
() => page.$eval('.view', (node) => window.getComputedStyle(node).color),
67-
'rgb(255, 0, 0)',
68-
)
65+
await untilUpdated(() => getColor('.view'), 'red')
6966
})
7067

7168
test('should load dynamic import with vars', async () => {

0 commit comments

Comments
 (0)