Skip to content

Commit

Permalink
Simplify test checks (vercel#14094)
Browse files Browse the repository at this point in the history
  • Loading branch information
Timer authored and rokinsky committed Jul 11, 2020
1 parent 43bc56b commit d39d859
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 52 deletions.
59 changes: 12 additions & 47 deletions test/integration/config/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ describe('Configuration', () => {

await check(
() => browser.elementByCss('.hello-world').getComputedCss('font-size'),
{
test(content) {
return content === '100px'
},
}
'100px'
)
} finally {
if (browser) {
Expand All @@ -75,11 +71,7 @@ describe('Configuration', () => {
browser
.elementByCss('.hello-world')
.getComputedCss('background-color'),
{
test(content) {
return content === 'rgba(0, 0, 255, 1)'
},
}
'rgba(0, 0, 255, 1)'
)
} finally {
if (browser) {
Expand Down Expand Up @@ -128,18 +120,11 @@ describe('Configuration', () => {
try {
browser = await webdriver(context.appPort, '/webpack-css')

await check(
async () => {
const pTag = await browser.elementByCss('.hello-world')
const initialFontSize = await pTag.getComputedCss('font-size')
return initialFontSize
},
{
test(content) {
return content === '100px'
},
}
)
await check(async () => {
const pTag = await browser.elementByCss('.hello-world')
const initialFontSize = await pTag.getComputedCss('font-size')
return initialFontSize
}, '100px')

const pagePath = join(
__dirname,
Expand All @@ -159,11 +144,7 @@ describe('Configuration', () => {
await check(
() =>
browser.elementByCss('.hello-world').getComputedCss('font-size'),
{
test(content) {
return content === '200px'
},
}
'200px'
)
} finally {
// Finally is used so that we revert the content back to the original regardless of the test outcome
Expand All @@ -173,11 +154,7 @@ describe('Configuration', () => {
await check(
() =>
browser.elementByCss('.hello-world').getComputedCss('font-size'),
{
test(content) {
return content === '100px'
},
}
'100px'
)
}
} finally {
Expand All @@ -196,32 +173,20 @@ describe('Configuration', () => {
browser = await webdriver(context.appPort, '/webpack-css')
await check(
() => browser.elementByCss('.hello-world').getComputedCss('color'),
{
test(content) {
return content === 'rgba(255, 255, 0, 1)'
},
}
'rgba(255, 255, 0, 1)'
)

try {
file.replace('yellow', 'red')
await check(
() => browser.elementByCss('.hello-world').getComputedCss('color'),
{
test(content) {
return content === 'rgba(255, 0, 0, 1)'
},
}
'rgba(255, 0, 0, 1)'
)
} finally {
file.restore()
await check(
() => browser.elementByCss('.hello-world').getComputedCss('color'),
{
test(content) {
return content === 'rgba(255, 255, 0, 1)'
},
}
'rgba(255, 255, 0, 1)'
)
}
} finally {
Expand Down
6 changes: 1 addition & 5 deletions test/integration/css/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,7 @@ describe('CSS Support', () => {
browser.eval(
`window.getComputedStyle(document.querySelector('.red-text')).color`
),
{
test(content) {
return content === 'rgb(128, 0, 128)'
},
}
'rgb(128, 0, 128)'
)

// ensure text remained
Expand Down

0 comments on commit d39d859

Please sign in to comment.