Skip to content

Commit

Permalink
Update RegExp test and remove extra script (#11006)
Browse files Browse the repository at this point in the history
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
  • Loading branch information
ijjk and Timer committed Mar 12, 2020
1 parent 8f8030f commit 9943334
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 21 deletions.
3 changes: 1 addition & 2 deletions .eslintignore
Expand Up @@ -3,5 +3,4 @@ node_modules
**/_next/**
**/dist/**
examples/with-ioc/**
examples/with-kea/**
test/integration/production/public/**/*
examples/with-kea/**
3 changes: 1 addition & 2 deletions .prettierignore
@@ -1,5 +1,4 @@
node_modules
**/.next/**
**/_next/**
**/dist/**
test/integration/production/public/**/*
**/dist/**
3 changes: 1 addition & 2 deletions .prettierignore_staged
@@ -1,4 +1,3 @@
**/.next/**
**/_next/**
**/dist/**
test/integration/production/public/**/*
**/dist/**
15 changes: 13 additions & 2 deletions test/integration/production/pages/regexp-polyfill.js
@@ -1,12 +1,23 @@
export default () => {
import * as React from 'react'

const Home = () => {
if (typeof window !== 'undefined') {
window.didRender = true
}

React.useEffect(() => {
// If this script is loaded before the polyfills it will
// still fail
const el = document.createElement('script')
el.src = '/regexp-test.js'
document.querySelector('body').appendChild(el)
}, [])

return (
<>
<p>hi</p>
<script src="/regexp-test.js" />
</>
)
}

export default Home
25 changes: 12 additions & 13 deletions test/integration/production/public/regexp-test.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions test/integration/production/test/index.test.js
Expand Up @@ -64,6 +64,12 @@ describe('Production Usage', () => {
it('should polyfill RegExp successfully', async () => {
const browser = await webdriver(appPort, '/regexp-polyfill')
expect(await browser.eval('window.didRender')).toBe(true)
// wait a second for the script to be loaded
await waitFor(1000)

expect(await browser.eval('window.isSticky')).toBe(true)
expect(await browser.eval('window.isMatch1')).toBe(true)
expect(await browser.eval('window.isMatch2')).toBe(false)
})
}

Expand Down

0 comments on commit 9943334

Please sign in to comment.