feature/fetch-fonts #14
@@ -4,6 +4,7 @@ import {
|
|||||||
it,
|
it,
|
||||||
} from 'vitest';
|
} from 'vitest';
|
||||||
import type {
|
import type {
|
||||||
|
FontItem,
|
||||||
FontshareFont,
|
FontshareFont,
|
||||||
GoogleFontItem,
|
GoogleFontItem,
|
||||||
} from '../../model/types';
|
} from '../../model/types';
|
||||||
@@ -82,42 +83,42 @@ describe('Font Normalization', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('handles sans-serif category', () => {
|
it('handles sans-serif category', () => {
|
||||||
const font = { ...mockGoogleFont, category: 'sans-serif' };
|
const font: FontItem = { ...mockGoogleFont, category: 'sans-serif' };
|
||||||
const result = normalizeGoogleFont(font);
|
const result = normalizeGoogleFont(font);
|
||||||
|
|
||||||
expect(result.category).toBe('sans-serif');
|
expect(result.category).toBe('sans-serif');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handles serif category', () => {
|
it('handles serif category', () => {
|
||||||
const font = { ...mockGoogleFont, category: 'serif' };
|
const font: FontItem = { ...mockGoogleFont, category: 'serif' };
|
||||||
const result = normalizeGoogleFont(font);
|
const result = normalizeGoogleFont(font);
|
||||||
|
|
||||||
expect(result.category).toBe('serif');
|
expect(result.category).toBe('serif');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handles display category', () => {
|
it('handles display category', () => {
|
||||||
const font = { ...mockGoogleFont, category: 'display' };
|
const font: FontItem = { ...mockGoogleFont, category: 'display' };
|
||||||
const result = normalizeGoogleFont(font);
|
const result = normalizeGoogleFont(font);
|
||||||
|
|
||||||
expect(result.category).toBe('display');
|
expect(result.category).toBe('display');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handles handwriting category', () => {
|
it('handles handwriting category', () => {
|
||||||
const font = { ...mockGoogleFont, category: 'handwriting' };
|
const font: FontItem = { ...mockGoogleFont, category: 'handwriting' };
|
||||||
const result = normalizeGoogleFont(font);
|
const result = normalizeGoogleFont(font);
|
||||||
|
|
||||||
expect(result.category).toBe('handwriting');
|
expect(result.category).toBe('handwriting');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handles cursive category (maps to handwriting)', () => {
|
it('handles cursive category (maps to handwriting)', () => {
|
||||||
const font = { ...mockGoogleFont, category: 'cursive' };
|
const font: FontItem = { ...mockGoogleFont, category: 'cursive' };
|
||||||
const result = normalizeGoogleFont(font);
|
const result = normalizeGoogleFont(font);
|
||||||
|
|
||||||
expect(result.category).toBe('handwriting');
|
expect(result.category).toBe('handwriting');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handles monospace category', () => {
|
it('handles monospace category', () => {
|
||||||
const font = { ...mockGoogleFont, category: 'monospace' };
|
const font: FontItem = { ...mockGoogleFont, category: 'monospace' };
|
||||||
const result = normalizeGoogleFont(font);
|
const result = normalizeGoogleFont(font);
|
||||||
|
|
||||||
expect(result.category).toBe('monospace');
|
expect(result.category).toBe('monospace');
|
||||||
@@ -522,22 +523,6 @@ describe('Font Normalization', () => {
|
|||||||
|
|
||||||
expect(result.category).toBe('sans-serif'); // fallback
|
expect(result.category).toBe('sans-serif'); // fallback
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handles unknown Google Font category', () => {
|
|
||||||
const font: GoogleFontItem = {
|
|
||||||
family: 'Test',
|
|
||||||
category: 'unknown',
|
|
||||||
variants: ['regular'],
|
|
||||||
subsets: ['latin'],
|
|
||||||
files: { regular: 'url' },
|
|
||||||
version: 'v1',
|
|
||||||
lastModified: '2022-01-01',
|
|
||||||
menu: 'https://fonts.googleapis.com/css2?family=Test',
|
|
||||||
};
|
|
||||||
const result = normalizeGoogleFont(font);
|
|
||||||
|
|
||||||
expect(result.category).toBe('sans-serif'); // fallback
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user