|
1 | 1 | import { describe, expect, it } from 'vitest' |
2 | 2 | import { |
| 3 | + createDefaultInputFormatField, |
3 | 4 | extractInputFieldsFromBlocks, |
4 | 5 | normalizeInputFormatValue, |
5 | 6 | } from '@/lib/workflows/input-format' |
@@ -227,3 +228,28 @@ describe('normalizeInputFormatValue', () => { |
227 | 228 | expect(normalizeInputFormatValue(input)).toEqual(input) |
228 | 229 | }) |
229 | 230 | }) |
| 231 | + |
| 232 | +describe('createDefaultInputFormatField', () => { |
| 233 | + it.concurrent('creates an empty field with the canonical default shape', () => { |
| 234 | + const field = createDefaultInputFormatField() |
| 235 | + expect(field).toEqual({ |
| 236 | + id: expect.any(String), |
| 237 | + name: '', |
| 238 | + type: 'string', |
| 239 | + value: '', |
| 240 | + collapsed: false, |
| 241 | + }) |
| 242 | + expect(field.id.length).toBeGreaterThan(0) |
| 243 | + }) |
| 244 | + |
| 245 | + it.concurrent('omits description so it is not persisted by default', () => { |
| 246 | + expect('description' in createDefaultInputFormatField()).toBe(false) |
| 247 | + }) |
| 248 | + |
| 249 | + it.concurrent('returns a fresh id and a new object on each call', () => { |
| 250 | + const first = createDefaultInputFormatField() |
| 251 | + const second = createDefaultInputFormatField() |
| 252 | + expect(first.id).not.toBe(second.id) |
| 253 | + expect(first).not.toBe(second) |
| 254 | + }) |
| 255 | +}) |
0 commit comments