feat(devices): PATCH accepts icon ref
Export reusable iconRef zod validator (set:<set>:<name> | brand:<slug> | null) and add it as an optional field to patchBody so PATCH /devices/:mac accepts icon. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
15
tests/icons/devices_icon.test.js
Normal file
15
tests/icons/devices_icon.test.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { z } from 'zod';
|
||||
import { iconRef } from '../../lib/api/routes/devices.js';
|
||||
|
||||
describe('icon ref validation', () => {
|
||||
it('accepts set + brand refs and null', () => {
|
||||
expect(iconRef.safeParse('set:devices:router').success).toBe(true);
|
||||
expect(iconRef.safeParse('brand:apple').success).toBe(true);
|
||||
expect(iconRef.safeParse(null).success).toBe(true);
|
||||
});
|
||||
it('rejects junk', () => {
|
||||
expect(iconRef.safeParse('set:bad').success).toBe(false);
|
||||
expect(iconRef.safeParse('javascript:alert').success).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user