diff --git a/tests/unit/constants/icon-map.test.ts b/tests/unit/constants/icon-map.test.ts new file mode 100644 index 0000000..5d29ae6 --- /dev/null +++ b/tests/unit/constants/icon-map.test.ts @@ -0,0 +1,47 @@ +import { describe, it, expect } from 'vitest'; +import { iconMap } from '$lib/constants/icon-map'; + +describe('Icon Map', () => { + it('should export iconMap object', () => { + expect(iconMap).toBeDefined(); + expect(typeof iconMap).toBe('object'); + }); + + it('should have SVG content for each icon', () => { + const icons = Object.keys(iconMap); + expect(icons.length).toBeGreaterThan(0); + + icons.forEach((iconName) => { + expect(iconMap[iconName]).toBeDefined(); + expect(typeof iconMap[iconName]).toBe('string'); + expect(iconMap[iconName]).toContain(''); + }); + }); + + it('should have commonly used icons', () => { + const commonIcons = [ + 'check', + 'alert-circle', + 'alert-triangle', + 'chevron-down', + 'chevron-right', + 'loader', + ]; + + commonIcons.forEach((iconName) => { + expect(iconMap[iconName]).toBeDefined(); + }); + }); + + it('should have valid SVG viewBox attributes', () => { + const icons = Object.keys(iconMap); + + icons.forEach((iconName) => { + const svg = iconMap[iconName]; + if (svg.includes('viewBox')) { + expect(svg).toMatch(/viewBox="[^"]+"/); + } + }); + }); +}); diff --git a/tests/unit/content/axfr.test.ts b/tests/unit/content/axfr.test.ts new file mode 100644 index 0000000..9fc3ed4 --- /dev/null +++ b/tests/unit/content/axfr.test.ts @@ -0,0 +1,100 @@ +import { describe, it, expect } from 'vitest'; +import { axfrContent } from '$lib/content/axfr'; + +describe('AXFR Content', () => { + it('should have valid structure', () => { + expect(axfrContent).toBeDefined(); + expect(axfrContent.title).toBeDefined(); + expect(axfrContent.description).toBeDefined(); + expect(axfrContent.sections).toBeDefined(); + }); + + it('should have all required sections', () => { + expect(axfrContent.sections.whatIsAXFR).toBeDefined(); + expect(axfrContent.sections.security).toBeDefined(); + expect(axfrContent.sections.howItWorks).toBeDefined(); + expect(axfrContent.sections.interpretation).toBeDefined(); + expect(axfrContent.sections.properConfiguration).toBeDefined(); + expect(axfrContent.sections.remediation).toBeDefined(); + expect(axfrContent.sections.bestPractices).toBeDefined(); + expect(axfrContent.sections.commonMisconfigurations).toBeDefined(); + expect(axfrContent.sections.compliance).toBeDefined(); + }); + + it('should have security risks', () => { + expect(axfrContent.sections.security.risks).toBeInstanceOf(Array); + expect(axfrContent.sections.security.risks.length).toBeGreaterThan(0); + + axfrContent.sections.security.risks.forEach((risk) => { + expect(risk.risk).toBeDefined(); + expect(risk.severity).toBeDefined(); + expect(risk.description).toBeDefined(); + expect(risk.impact).toBeDefined(); + }); + }); + + it('should have interpretation statuses', () => { + expect(axfrContent.sections.interpretation.statuses).toBeInstanceOf(Array); + expect(axfrContent.sections.interpretation.statuses.length).toBeGreaterThan(0); + + axfrContent.sections.interpretation.statuses.forEach((status) => { + expect(status.status).toBeDefined(); + expect(status.color).toBeDefined(); + expect(status.meaning).toBeDefined(); + expect(status.description).toBeDefined(); + expect(status.action).toBeDefined(); + }); + }); + + it('should have configuration examples', () => { + expect(axfrContent.sections.properConfiguration.configurations).toBeInstanceOf(Array); + expect(axfrContent.sections.properConfiguration.configurations.length).toBeGreaterThan(0); + + axfrContent.sections.properConfiguration.configurations.forEach((config) => { + expect(config.server).toBeDefined(); + expect(config.syntax).toBeDefined(); + expect(config.description).toBeDefined(); + }); + }); + + it('should have remediation steps', () => { + expect(axfrContent.sections.remediation.steps).toBeInstanceOf(Array); + expect(axfrContent.sections.remediation.steps.length).toBeGreaterThan(0); + + axfrContent.sections.remediation.steps.forEach((step) => { + expect(step.step).toBeDefined(); + expect(step.details).toBeDefined(); + }); + }); + + it('should have best practices', () => { + expect(axfrContent.sections.bestPractices.practices).toBeInstanceOf(Array); + expect(axfrContent.sections.bestPractices.practices.length).toBeGreaterThan(0); + + axfrContent.sections.bestPractices.practices.forEach((practice) => { + expect(practice.practice).toBeDefined(); + expect(practice.description).toBeDefined(); + }); + }); + + it('should have common misconfigurations', () => { + expect(axfrContent.sections.commonMisconfigurations.misconfigurations).toBeInstanceOf(Array); + expect(axfrContent.sections.commonMisconfigurations.misconfigurations.length).toBeGreaterThan(0); + + axfrContent.sections.commonMisconfigurations.misconfigurations.forEach((misconfig) => { + expect(misconfig.issue).toBeDefined(); + expect(misconfig.problem).toBeDefined(); + expect(misconfig.fix).toBeDefined(); + }); + }); + + it('should have compliance standards', () => { + expect(axfrContent.sections.compliance.standards).toBeInstanceOf(Array); + expect(axfrContent.sections.compliance.standards.length).toBeGreaterThan(0); + + axfrContent.sections.compliance.standards.forEach((standard) => { + expect(standard.standard).toBeDefined(); + expect(standard.requirement).toBeDefined(); + }); + }); +}); diff --git a/tests/unit/content/dns-performance.test.ts b/tests/unit/content/dns-performance.test.ts new file mode 100644 index 0000000..536589f --- /dev/null +++ b/tests/unit/content/dns-performance.test.ts @@ -0,0 +1,60 @@ +import { describe, it, expect } from 'vitest'; +import { dnsPerformanceContent } from '$lib/content/dns-performance'; + +describe('DNS Performance Content', () => { + it('should have valid structure', () => { + expect(dnsPerformanceContent).toBeDefined(); + expect(dnsPerformanceContent.title).toBeDefined(); + expect(dnsPerformanceContent.description).toBeDefined(); + expect(dnsPerformanceContent.sections).toBeDefined(); + }); + + it('should have all required sections', () => { + expect(dnsPerformanceContent.sections.whatIsDnsPerformance).toBeDefined(); + expect(dnsPerformanceContent.sections.howItWorks).toBeDefined(); + expect(dnsPerformanceContent.sections.recordTypes).toBeDefined(); + expect(dnsPerformanceContent.sections.interpretingResults).toBeDefined(); + expect(dnsPerformanceContent.sections.optimization).toBeDefined(); + expect(dnsPerformanceContent.sections.bestPractices).toBeDefined(); + }); + + it('should have record types', () => { + expect(dnsPerformanceContent.sections.recordTypes.types).toBeInstanceOf(Array); + expect(dnsPerformanceContent.sections.recordTypes.types.length).toBeGreaterThan(0); + + dnsPerformanceContent.sections.recordTypes.types.forEach((type) => { + expect(type.type).toBeDefined(); + expect(type.description).toBeDefined(); + }); + }); + + it('should have interpretation ranges', () => { + expect(dnsPerformanceContent.sections.interpretingResults.ranges).toBeInstanceOf(Array); + expect(dnsPerformanceContent.sections.interpretingResults.ranges.length).toBeGreaterThan(0); + + dnsPerformanceContent.sections.interpretingResults.ranges.forEach((range) => { + expect(range.range).toBeDefined(); + expect(range.performance).toBeDefined(); + expect(range.description).toBeDefined(); + }); + }); + + it('should have optimization tips', () => { + expect(dnsPerformanceContent.sections.optimization.tips).toBeInstanceOf(Array); + expect(dnsPerformanceContent.sections.optimization.tips.length).toBeGreaterThan(0); + + dnsPerformanceContent.sections.optimization.tips.forEach((tip) => { + expect(tip.tip).toBeDefined(); + expect(tip.description).toBeDefined(); + }); + }); + + it('should have best practices', () => { + expect(dnsPerformanceContent.sections.bestPractices.practices).toBeInstanceOf(Array); + expect(dnsPerformanceContent.sections.bestPractices.practices.length).toBeGreaterThan(0); + + dnsPerformanceContent.sections.bestPractices.practices.forEach((practice) => { + expect(typeof practice).toBe('string'); + }); + }); +}); diff --git a/tests/unit/content/dnsbl.test.ts b/tests/unit/content/dnsbl.test.ts new file mode 100644 index 0000000..54b8b2c --- /dev/null +++ b/tests/unit/content/dnsbl.test.ts @@ -0,0 +1,61 @@ +import { describe, it, expect } from 'vitest'; +import { dnsblContent } from '$lib/content/dnsbl'; + +describe('DNSBL Content', () => { + it('should have valid structure', () => { + expect(dnsblContent).toBeDefined(); + expect(dnsblContent.title).toBeDefined(); + expect(dnsblContent.description).toBeDefined(); + expect(dnsblContent.sections).toBeDefined(); + }); + + it('should have all required sections', () => { + expect(dnsblContent.sections.whatAreBlacklists).toBeDefined(); + expect(dnsblContent.sections.howChecksWork).toBeDefined(); + expect(dnsblContent.sections.whyListed).toBeDefined(); + expect(dnsblContent.sections.consequences).toBeDefined(); + expect(dnsblContent.sections.howToFix).toBeDefined(); + expect(dnsblContent.sections.bestPractices).toBeDefined(); + }); + + it('should have listing reasons', () => { + expect(dnsblContent.sections.whyListed.reasons).toBeInstanceOf(Array); + expect(dnsblContent.sections.whyListed.reasons.length).toBeGreaterThan(0); + + dnsblContent.sections.whyListed.reasons.forEach((reason) => { + expect(reason.reason).toBeDefined(); + expect(reason.description).toBeDefined(); + }); + }); + + it('should have consequences', () => { + expect(dnsblContent.sections.consequences.impacts).toBeInstanceOf(Array); + expect(dnsblContent.sections.consequences.impacts.length).toBeGreaterThan(0); + + dnsblContent.sections.consequences.impacts.forEach((impact) => { + expect(impact.severity).toBeDefined(); + expect(impact.impact).toBeDefined(); + expect(impact.description).toBeDefined(); + }); + }); + + it('should have fix steps', () => { + expect(dnsblContent.sections.howToFix.steps).toBeInstanceOf(Array); + expect(dnsblContent.sections.howToFix.steps.length).toBeGreaterThan(0); + + dnsblContent.sections.howToFix.steps.forEach((step) => { + expect(step.step).toBeDefined(); + expect(step.actions).toBeInstanceOf(Array); + }); + }); + + it('should have best practices', () => { + expect(dnsblContent.sections.bestPractices.practices).toBeInstanceOf(Array); + expect(dnsblContent.sections.bestPractices.practices.length).toBeGreaterThan(0); + + dnsblContent.sections.bestPractices.practices.forEach((practice) => { + expect(practice.category).toBeDefined(); + expect(practice.items).toBeInstanceOf(Array); + }); + }); +});