"""Tests for components and standard library.""" import uframe def test_inline_component(): source = '''page "Test" 50 component greeting(name) heading 1 "Hello $name" text "Welcome, $name!" greeting "Alice" greeting "Bob"''' result = uframe.compile(source) assert "Hello Alice" in result.ascii assert "Welcome, Alice!" in result.ascii assert "Hello Bob" in result.ascii assert "Welcome, Bob!" in result.ascii def test_component_with_gauge(): source = '''page "Test" 50 component stat(label, value, max) gauge "$label" $value $max 20 stat "CPU" 62 100 stat "MEM" 84 100''' result = uframe.compile(source) assert "CPU" in result.ascii assert "MEM" in result.ascii assert "█" in result.ascii def test_use_std_dashboard(): source = '''page "Test" 60 use std/dashboard banner "My Node" "Mesh Network"''' result = uframe.compile(source) assert "My Node" in result.ascii assert "Mesh Network" in result.ascii assert "╔" in result.ascii # double box from banner def test_use_std_dashboard_resources(): source = '''page "Test" 60 use std/dashboard resources 42 67''' result = uframe.compile(source) assert "CPU" in result.ascii assert "MEM" in result.ascii assert "Resources" in result.ascii def test_use_std_nav(): source = '''page "Test" 50 use std/nav nav_link "Home" "/page/index.mu" nav_divider nav_link "About" "/page/about.mu"''' result = uframe.compile(source) assert "Home" in result.ascii assert "About" in result.ascii def test_unknown_component_ignored(): source = '''page "Test" 50 heading 1 "Hello" nonexistent_thing "arg"''' result = uframe.compile(source) assert "Hello" in result.ascii