mirror of
https://github.com/django-components/django-components.git
synced 2025-08-30 18:57:20 +00:00
fix: ensure consistent order of scripts in Component.Media.js (#783)
This commit is contained in:
parent
2a4b0f5289
commit
5fc27a041f
2 changed files with 29 additions and 8 deletions
|
@ -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">\`)];"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue