|
| 1 | +import { describe, expect, it } from 'vitest'; |
| 2 | +import { axePluginOptionsSchema } from './config.js'; |
| 3 | + |
| 4 | +describe('axePluginOptionsSchema', () => { |
| 5 | + it('should accept empty options object with default preset', () => { |
| 6 | + expect(axePluginOptionsSchema.parse({}).preset).toBe('wcag21aa'); |
| 7 | + }); |
| 8 | + |
| 9 | + it('should accept wcag21aa preset', () => { |
| 10 | + expect(() => |
| 11 | + axePluginOptionsSchema.parse({ preset: 'wcag21aa' }), |
| 12 | + ).not.toThrow(); |
| 13 | + }); |
| 14 | + |
| 15 | + it('should accept wcag22aa preset', () => { |
| 16 | + expect(() => |
| 17 | + axePluginOptionsSchema.parse({ preset: 'wcag22aa' }), |
| 18 | + ).not.toThrow(); |
| 19 | + }); |
| 20 | + |
| 21 | + it('should accept best-practice preset', () => { |
| 22 | + expect(() => |
| 23 | + axePluginOptionsSchema.parse({ preset: 'best-practice' }), |
| 24 | + ).not.toThrow(); |
| 25 | + }); |
| 26 | + |
| 27 | + it('should accept all preset', () => { |
| 28 | + expect(() => axePluginOptionsSchema.parse({ preset: 'all' })).not.toThrow(); |
| 29 | + }); |
| 30 | + |
| 31 | + it('should accept number scoreTargets', () => { |
| 32 | + expect(() => |
| 33 | + axePluginOptionsSchema.parse({ scoreTargets: 0.99 }), |
| 34 | + ).not.toThrow(); |
| 35 | + }); |
| 36 | + |
| 37 | + it('should accept object scoreTargets', () => { |
| 38 | + expect(() => |
| 39 | + axePluginOptionsSchema.parse({ |
| 40 | + scoreTargets: { 'color-contrast': 0.99 }, |
| 41 | + }), |
| 42 | + ).not.toThrow(); |
| 43 | + }); |
| 44 | + |
| 45 | + it('should throw for invalid preset', () => { |
| 46 | + expect(() => axePluginOptionsSchema.parse({ preset: 'wcag3aa' })).toThrow(); |
| 47 | + }); |
| 48 | + |
| 49 | + it('should throw for invalid scoreTargets value', () => { |
| 50 | + expect(() => axePluginOptionsSchema.parse({ scoreTargets: 1.5 })).toThrow(); |
| 51 | + }); |
| 52 | + |
| 53 | + it('should throw for negative scoreTargets', () => { |
| 54 | + expect(() => |
| 55 | + axePluginOptionsSchema.parse({ scoreTargets: -0.1 }), |
| 56 | + ).toThrow(); |
| 57 | + }); |
| 58 | +}); |
0 commit comments