Skip to content

Commit a601ba0

Browse files
committed
feat: add test
1 parent 3a93d5d commit a601ba0

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

tests/integration/app-document/src/sub/Document.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ export default function Document(): React.ReactElement {
5555
console.log('this is a IIFE function');
5656
}}
5757
/>
58+
<Script
59+
defer
60+
async
61+
id="script-has-id2"
62+
content={() => {
63+
console.log('this is another IIFE function');
64+
}}
65+
/>
5866
</Head>
5967
<Body {...{ dir: 'ltr' }}>
6068
<Root {...{ class: 'root' }}>

tests/integration/app-document/tests/index.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,21 @@ describe('test dev and build', () => {
172172
htmlWithDoc.includes('console.log("this is a IIFE function")'),
173173
).toBe(true);
174174
});
175+
176+
test('should not break Script origin script properties', async () => {
177+
const htmlWithDoc = fs.readFileSync(
178+
path.join(appDir, 'dist', 'html/sub/index.html'),
179+
'utf-8',
180+
);
181+
182+
expect(
183+
htmlWithDoc.includes('<script defer="" async="" id="script-has-id2">'),
184+
).toBe(true);
185+
// IIFE should worked
186+
expect(
187+
htmlWithDoc.includes('console.log("this is another IIFE function")'),
188+
).toBe(true);
189+
});
175190
});
176191

177192
describe('test dev', () => {

0 commit comments

Comments
 (0)