24-3: signature balance component — implemented, QA Review
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
test('hero balance with a label is an img with viewBox and mode', function () {
|
||||
$html = (string) $this->blade('<x-site.balance mode="hero" label="ميزان العدالة" />');
|
||||
|
||||
expect($html)
|
||||
->toContain('<svg')
|
||||
->toContain('class="site-balance"')
|
||||
->toContain('data-balance="hero"')
|
||||
->toContain('viewBox="0 0 400 400"')
|
||||
->toContain('role="img"')
|
||||
->toContain('aria-label="ميزان العدالة"')
|
||||
->not->toContain('aria-hidden');
|
||||
});
|
||||
|
||||
test('balance without a label is hidden from assistive tech and defaults to static', function () {
|
||||
$html = (string) $this->blade('<x-site.balance />');
|
||||
|
||||
expect($html)->toContain('aria-hidden="true"')->toContain('data-balance="static"')->not->toContain('role="img"');
|
||||
});
|
||||
|
||||
test('size sets width and height and attributes pass through', function () {
|
||||
$html = (string) $this->blade('<x-site.balance size="120" class="x-extra" id="b1" />');
|
||||
|
||||
expect($html)->toContain('width="120"')->toContain('height="120"')->toContain('x-extra')->toContain('id="b1"');
|
||||
});
|
||||
|
||||
test('balance script is wired into public.js and ids are made unique per instance', function () {
|
||||
$public = file_get_contents(resource_path('js/public.js'));
|
||||
$balance = file_get_contents(resource_path('js/site/balance.js'));
|
||||
|
||||
expect($public)->toContain("./site/balance.js");
|
||||
expect($balance)->toContain('export function init')->toContain('export function destroy')
|
||||
->toContain('id="gd${i}"')->toContain('id="sh${i}"')->toContain('++uid')
|
||||
->toContain('rotate(${deg} 200 110)')->toContain('* 0.028')->toContain('prefers-reduced-motion');
|
||||
});
|
||||
|
||||
test('balance css is scoped', function () {
|
||||
expect(file_get_contents(resource_path('css/public.css')))->toContain('body.site .site-balance{display:block;overflow:visible}');
|
||||
});
|
||||
Reference in New Issue
Block a user