Skip to content

Commit

Permalink
test(vercel#39993): add case for inline script
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Aug 27, 2022
1 parent 2c6834c commit edbb4ba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 10 additions & 2 deletions test/integration/script-loader/base/pages/page10.js
Expand Up @@ -2,7 +2,8 @@ import Script from 'next/script'
import Link from 'next/link'

if (typeof window !== 'undefined') {
window.onReadyCalls ??= 0
window.remoteScriptsOnReadyCalls ??= 0
window.inlineScriptsOnReadyCalls ??= 0
}

const Page = () => {
Expand All @@ -13,7 +14,14 @@ const Page = () => {
<Script
src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js"
onReady={() => {
window.onReadyCalls++
window.remoteScriptsOnReadyCalls++
}}
/>
<Script
id="i-am-an-inline-script-that-has-on-ready"
dangerouslySetInnerHTML={{ __html: 'console.log("inline script!")' }}
onReady={() => {
window.inlineScriptsOnReadyCalls++
}}
/>
</div>
Expand Down
3 changes: 2 additions & 1 deletion test/integration/script-loader/test/index.test.js
Expand Up @@ -231,7 +231,8 @@ describe('Next.js Script - Primary Strategies', () => {

// wait for jQuery to be loaded
await waitFor(1000)
expect(await browser.eval(`window.onReadyCalls`)).toBe(1)
expect(await browser.eval(`window.remoteScriptsOnReadyCalls`)).toBe(1)
expect(await browser.eval(`window.inlineScriptsOnReadyCalls`)).toBe(1)
} finally {
if (browser) await browser.close()
if (devApp) await killApp(devApp)
Expand Down

0 comments on commit edbb4ba

Please sign in to comment.