Merge pull request #39 from nesquena/fix/test-keyframe-parser
fix: test_send_pop_in keyframe parser found wrong @keyframes block
This commit is contained in:
@@ -178,12 +178,12 @@ def test_send_pop_in_keyframes_defined():
|
|||||||
assert '@keyframes' in css
|
assert '@keyframes' in css
|
||||||
|
|
||||||
|
|
||||||
def test_send_pop_in_uses_scale():
|
def _extract_keyframe(css, name):
|
||||||
"""send-pop-in keyframe must animate from a scaled-down state."""
|
"""Extract the full @keyframes block for the given animation name."""
|
||||||
css, _ = get_text("/static/style.css")
|
# Find '@keyframes <name>' directly (forward search) to avoid hitting
|
||||||
kf_idx = css.find('send-pop-in')
|
# an earlier keyframe when multiple are defined on the same line.
|
||||||
kf_start = css.rfind('@keyframes', 0, kf_idx)
|
kf_start = css.find('@keyframes ' + name)
|
||||||
# Find matching closing brace (simple scan)
|
assert kf_start != -1, f"@keyframes {name} not found in CSS"
|
||||||
depth = 0
|
depth = 0
|
||||||
kf_end = kf_start
|
kf_end = kf_start
|
||||||
for i, ch in enumerate(css[kf_start:], kf_start):
|
for i, ch in enumerate(css[kf_start:], kf_start):
|
||||||
@@ -194,26 +194,20 @@ def test_send_pop_in_uses_scale():
|
|||||||
if depth == 0:
|
if depth == 0:
|
||||||
kf_end = i
|
kf_end = i
|
||||||
break
|
break
|
||||||
kf_rule = css[kf_start:kf_end]
|
return css[kf_start:kf_end]
|
||||||
|
|
||||||
|
|
||||||
|
def test_send_pop_in_uses_scale():
|
||||||
|
"""send-pop-in keyframe must animate from a scaled-down state."""
|
||||||
|
css, _ = get_text("/static/style.css")
|
||||||
|
kf_rule = _extract_keyframe(css, 'send-pop-in')
|
||||||
assert 'scale' in kf_rule
|
assert 'scale' in kf_rule
|
||||||
|
|
||||||
|
|
||||||
def test_send_pop_in_uses_opacity():
|
def test_send_pop_in_uses_opacity():
|
||||||
"""send-pop-in keyframe must fade in (opacity transition)."""
|
"""send-pop-in keyframe must fade in (opacity transition)."""
|
||||||
css, _ = get_text("/static/style.css")
|
css, _ = get_text("/static/style.css")
|
||||||
kf_idx = css.find('send-pop-in')
|
kf_rule = _extract_keyframe(css, 'send-pop-in')
|
||||||
kf_start = css.rfind('@keyframes', 0, kf_idx)
|
|
||||||
depth = 0
|
|
||||||
kf_end = kf_start
|
|
||||||
for i, ch in enumerate(css[kf_start:], kf_start):
|
|
||||||
if ch == '{':
|
|
||||||
depth += 1
|
|
||||||
elif ch == '}':
|
|
||||||
depth -= 1
|
|
||||||
if depth == 0:
|
|
||||||
kf_end = i
|
|
||||||
break
|
|
||||||
kf_rule = css[kf_start:kf_end]
|
|
||||||
assert 'opacity' in kf_rule
|
assert 'opacity' in kf_rule
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user