test: add comprehensive test suite for components, composables, and pages
Add 16 new test files covering: - Composables: useBackend, useMeta, useDataJson - Type classes: QueryResult, ResumeContent - UI components: BadgeList, BadgeListCard - Navbar components: LanguageSwitcher, ThemeSwitcher - App components: AppNavbar, AppFooter - VocalSynth components: Projects, Tools - Pages: contact, resume, [...slug] Tests focus on pure logic, interfaces, and component rendering where possible, avoiding complex mocking of Nuxt auto-imported composables. Total: 174 tests across 17 test files (including existing useApi tests).
This commit is contained in:
129
app/types/resume.test.ts
Normal file
129
app/types/resume.test.ts
Normal file
@@ -0,0 +1,129 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { ResumeExperience, ResumeContent } from './resume';
|
||||
import type { Tool } from './tool';
|
||||
|
||||
describe('ResumeExperience', () => {
|
||||
describe('initialization', () => {
|
||||
it('should initialize with empty tools array', () => {
|
||||
const experience = new ResumeExperience();
|
||||
expect(experience.tools).toEqual([]);
|
||||
});
|
||||
|
||||
it('should initialize with undefined description', () => {
|
||||
const experience = new ResumeExperience();
|
||||
expect(experience.description).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('property assignment', () => {
|
||||
it('should allow tools to be assigned', () => {
|
||||
const experience = new ResumeExperience();
|
||||
const tools: Tool[] = [{ name: 'TypeScript', link: 'https://typescriptlang.org' }, { name: 'Vue.js' }];
|
||||
experience.tools = tools;
|
||||
expect(experience.tools).toEqual(tools);
|
||||
});
|
||||
|
||||
it('should allow description to be assigned', () => {
|
||||
const experience = new ResumeExperience();
|
||||
experience.description = 'Software developer working on web applications';
|
||||
expect(experience.description).toBe('Software developer working on web applications');
|
||||
});
|
||||
});
|
||||
|
||||
describe('TimelineItem interface implementation', () => {
|
||||
it('should be usable as TimelineItem', () => {
|
||||
const experience = new ResumeExperience();
|
||||
// TimelineItem interface from @nuxt/ui - ResumeExperience implements it
|
||||
expect(experience).toHaveProperty('tools');
|
||||
expect(experience).toHaveProperty('description');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('ResumeContent', () => {
|
||||
describe('initialization', () => {
|
||||
it('should initialize with empty experience array', () => {
|
||||
const content = new ResumeContent();
|
||||
expect(content.experience).toEqual([]);
|
||||
});
|
||||
|
||||
it('should initialize with empty education array', () => {
|
||||
const content = new ResumeContent();
|
||||
expect(content.education).toEqual([]);
|
||||
});
|
||||
|
||||
it('should initialize with empty otherTools array', () => {
|
||||
const content = new ResumeContent();
|
||||
expect(content.otherTools).toEqual([]);
|
||||
});
|
||||
|
||||
it('should initialize with empty devops array', () => {
|
||||
const content = new ResumeContent();
|
||||
expect(content.devops).toEqual([]);
|
||||
});
|
||||
|
||||
it('should initialize with empty os array', () => {
|
||||
const content = new ResumeContent();
|
||||
expect(content.os).toEqual([]);
|
||||
});
|
||||
|
||||
it('should initialize with empty programmingLanguages array', () => {
|
||||
const content = new ResumeContent();
|
||||
expect(content.programmingLanguages).toEqual([]);
|
||||
});
|
||||
|
||||
it('should initialize with empty frameworks array', () => {
|
||||
const content = new ResumeContent();
|
||||
expect(content.frameworks).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('property assignment', () => {
|
||||
it('should allow experience to be assigned', () => {
|
||||
const content = new ResumeContent();
|
||||
const exp = new ResumeExperience();
|
||||
exp.description = 'Test job';
|
||||
content.experience = [exp];
|
||||
expect(content.experience.length).toBe(1);
|
||||
expect(content.experience[0].description).toBe('Test job');
|
||||
});
|
||||
|
||||
it('should allow tools arrays to be assigned', () => {
|
||||
const content = new ResumeContent();
|
||||
const tools: Tool[] = [{ name: 'Git', link: 'https://git-scm.com' }];
|
||||
|
||||
content.devops = tools;
|
||||
content.os = [{ name: 'Linux' }];
|
||||
content.programmingLanguages = [{ name: 'Rust', link: 'https://rust-lang.org' }];
|
||||
content.frameworks = [{ name: 'Nuxt', link: 'https://nuxt.com' }];
|
||||
content.otherTools = [{ name: 'Vim' }];
|
||||
|
||||
expect(content.devops).toEqual(tools);
|
||||
expect(content.os).toEqual([{ name: 'Linux' }]);
|
||||
expect(content.programmingLanguages).toEqual([{ name: 'Rust', link: 'https://rust-lang.org' }]);
|
||||
expect(content.frameworks).toEqual([{ name: 'Nuxt', link: 'https://nuxt.com' }]);
|
||||
expect(content.otherTools).toEqual([{ name: 'Vim' }]);
|
||||
});
|
||||
|
||||
it('should allow education to be assigned', () => {
|
||||
const content = new ResumeContent();
|
||||
content.education = [{ title: 'Computer Science', description: 'Master degree' }];
|
||||
expect(content.education.length).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('default values', () => {
|
||||
it('should provide safe defaults when used without data', () => {
|
||||
const content = new ResumeContent();
|
||||
|
||||
// All arrays should be empty but defined
|
||||
expect(Array.isArray(content.experience)).toBe(true);
|
||||
expect(Array.isArray(content.education)).toBe(true);
|
||||
expect(Array.isArray(content.otherTools)).toBe(true);
|
||||
expect(Array.isArray(content.devops)).toBe(true);
|
||||
expect(Array.isArray(content.os)).toBe(true);
|
||||
expect(Array.isArray(content.programmingLanguages)).toBe(true);
|
||||
expect(Array.isArray(content.frameworks)).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user