fix: ensure consistent order of scripts in Component.Media.js (#783)

This commit is contained in:
Juro Oravec 2024-11-26 22:55:14 +01:00 committed by GitHub
parent 2a4b0f5289
commit 5fc27a041f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 29 additions and 8 deletions

View file

@ -329,12 +329,16 @@ class DependencyRenderingTests(BaseTestCase):
self.assertEqual(
rendered.count("const loadedCssScripts = ["style.css", "style2.css"];"), 1
)
# JS ORDER - "script.js", "script2.js"
self.assertEqual(
rendered.count(
r"const toLoadJsScripts = [Components.unescapeJs(\`<script src="script.js"></script>\`), Components.unescapeJs(\`<script src="script2.js"></script>\`)];"
),
1,
)
# CSS ORDER - "style.css", "style2.css"
self.assertEqual(
rendered.count(
r"const toLoadCssScripts = [Components.unescapeJs(\`<link href="style.css" media="all" rel="stylesheet">\`), Components.unescapeJs(\`<link href="style2.css" media="all" rel="stylesheet">\`)];"
@ -413,12 +417,22 @@ class DependencyRenderingTests(BaseTestCase):
),
1,
)
# JS ORDER:
# - "script2.js" (from SimpleComponentNested)
# - "script.js" (from SimpleComponent inside SimpleComponentNested)
# - "xyz1.js" (from OtherComponent inserted into SimpleComponentNested)
self.assertEqual(
rendered.count(
r"const toLoadJsScripts = [Components.unescapeJs(\`<script src="script.js"></script>\`), Components.unescapeJs(\`<script src="script2.js"></script>\`), Components.unescapeJs(\`<script src="xyz1.js"></script>\`)];"
r"const toLoadJsScripts = [Components.unescapeJs(\`<script src="script2.js"></script>\`), Components.unescapeJs(\`<script src="script.js"></script>\`), Components.unescapeJs(\`<script src="xyz1.js"></script>\`)];"
),
1,
)
# CSS ORDER:
# - "style.css", "style2.css" (from SimpleComponentNested)
# - "style.css" (from SimpleComponent inside SimpleComponentNested)
# - "xyz1.css" (from OtherComponent inserted into SimpleComponentNested)
self.assertEqual(
rendered.count(
r"const toLoadCssScripts = [Components.unescapeJs(\`<link href="style.css" media="all" rel="stylesheet">\`), Components.unescapeJs(\`<link href="style2.css" media="all" rel="stylesheet">\`), Components.unescapeJs(\`<link href="xyz1.css" media="all" rel="stylesheet">\`)];"