48 lines
2.0 KiB
TypeScript
48 lines
2.0 KiB
TypeScript
import { mount } from '@vue/test-utils';
|
|
import { describe, expect, it } from 'vitest';
|
|
import BrandIcon from '@/components/BrandIcon.vue';
|
|
import content from '@/../content/public/portfolio-content.json';
|
|
import { brandIconFor, brandIconLabels } from '@/icons/brand-icons';
|
|
|
|
const toolkitLabels = content.toolkit.flatMap((group) => group.technologies.map((technology) => technology.name));
|
|
const socialLabels = content.contact.social.map((link) => link.service);
|
|
|
|
describe('official brand icon registry', () => {
|
|
it('resolves every toolkit technology in validated portfolio content', () => {
|
|
for (const label of toolkitLabels) {
|
|
const icon = brandIconFor(label);
|
|
expect(icon.title).toBeTruthy();
|
|
expect(icon.hex).toMatch(/^[0-9A-F]{6}$/u);
|
|
expect(icon.path.length).toBeGreaterThan(20);
|
|
expect(icon.source).toMatch(/^https:\/\//u);
|
|
expect(icon.license).toBeTruthy();
|
|
}
|
|
});
|
|
|
|
it('resolves every configured social service mark', () => {
|
|
for (const label of socialLabels) {
|
|
expect(brandIconFor(label)).toMatchObject({ title: label });
|
|
}
|
|
});
|
|
|
|
it('keeps the registry closed over all content-facing labels', () => {
|
|
expect(brandIconLabels).toEqual([
|
|
'Linux', 'Docker', 'Nginx', 'Proxmox / KVM', 'Git', 'Python', 'Vue.js',
|
|
'JavaScript', 'C# / .NET', 'Flutter / Dart', 'PostgreSQL / SQL',
|
|
'Headless WordPress', 'Java', 'GitHub', 'GitLab', 'LinkedIn',
|
|
]);
|
|
expect(() => brandIconFor('Unlisted technology')).toThrow(/No official brand icon/u);
|
|
});
|
|
|
|
it('renders a decorative, non-focusable SVG while leaving the visible label to its caller', () => {
|
|
const wrapper = mount(BrandIcon, { props: { label: 'Linux' } });
|
|
const svg = wrapper.get('svg');
|
|
|
|
expect(svg.attributes('aria-hidden')).toBe('true');
|
|
expect(svg.attributes('focusable')).toBe('false');
|
|
expect(svg.attributes('data-brand-icon')).toBe('Linux');
|
|
expect(svg.get('path').attributes('d')).toBe(brandIconFor('Linux').path);
|
|
expect(wrapper.text()).toBe('');
|
|
});
|
|
});
|