51 lines
2.3 KiB
TypeScript
51 lines
2.3 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 { brandIconAvailable, 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 with an honest official mark', () => {
|
|
for (const label of toolkitLabels.filter(brandIconAvailable)) {
|
|
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', 'cPanel', 'Authelia', 'Nextcloud', 'Proxmox/KVM',
|
|
'Git', 'Python', 'TypeScript/JavaScript', 'Vue.js', 'Flutter/Dart', 'Fastify',
|
|
'C#/.NET', 'Headless WordPress', 'Java', 'PostgreSQL', 'Drift/SQLite',
|
|
'Drizzle ORM', 'PyTorch', 'Ultralytics/YOLO', 'OpenCV', 'GitHub', 'GitLab', 'LinkedIn',
|
|
]);
|
|
expect(['DNS', 'TLS', 'Fail2Ban', 'Btrfs', 'rsync', 'SQL', 'SPSS', 'Microsoft Excel', 'SoccerNet']
|
|
.every((label) => !brandIconAvailable(label))).toBe(true);
|
|
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('');
|
|
});
|
|
});
|