|
| 1 | +import { getSupportedElicitationModes } from './elicitation-utils.js'; |
| 2 | + |
| 3 | +describe('elicitation-utils', () => { |
| 4 | + describe('getSupportedElicitationModes', () => { |
| 5 | + it('should support nothing when capabilities are undefined', () => { |
| 6 | + const result = getSupportedElicitationModes(undefined); |
| 7 | + expect(result.supportsFormMode).toBe(false); |
| 8 | + expect(result.supportsUrlMode).toBe(false); |
| 9 | + }); |
| 10 | + |
| 11 | + it('should default to form mode when capabilities are an empty object', () => { |
| 12 | + const result = getSupportedElicitationModes({}); |
| 13 | + expect(result.supportsFormMode).toBe(true); |
| 14 | + expect(result.supportsUrlMode).toBe(false); |
| 15 | + }); |
| 16 | + |
| 17 | + it('should support form mode when form is explicitly declared', () => { |
| 18 | + const result = getSupportedElicitationModes({ form: {} }); |
| 19 | + expect(result.supportsFormMode).toBe(true); |
| 20 | + expect(result.supportsUrlMode).toBe(false); |
| 21 | + }); |
| 22 | + |
| 23 | + it('should support url mode when url is explicitly declared', () => { |
| 24 | + const result = getSupportedElicitationModes({ url: {} }); |
| 25 | + expect(result.supportsFormMode).toBe(false); |
| 26 | + expect(result.supportsUrlMode).toBe(true); |
| 27 | + }); |
| 28 | + |
| 29 | + it('should support both modes when both are explicitly declared', () => { |
| 30 | + const result = getSupportedElicitationModes({ form: {}, url: {} }); |
| 31 | + expect(result.supportsFormMode).toBe(true); |
| 32 | + expect(result.supportsUrlMode).toBe(true); |
| 33 | + }); |
| 34 | + |
| 35 | + it('should support form mode when only applyDefaults is present', () => { |
| 36 | + const result = getSupportedElicitationModes({ applyDefaults: true }); |
| 37 | + expect(result.supportsFormMode).toBe(true); |
| 38 | + expect(result.supportsUrlMode).toBe(false); |
| 39 | + }); |
| 40 | + |
| 41 | + it('should support form mode when applyDefaults and form are present', () => { |
| 42 | + const result = getSupportedElicitationModes({ applyDefaults: true, form: {} }); |
| 43 | + expect(result.supportsFormMode).toBe(true); |
| 44 | + expect(result.supportsUrlMode).toBe(false); |
| 45 | + }); |
| 46 | + |
| 47 | + it('should support url mode when applyDefaults and url are present', () => { |
| 48 | + const result = getSupportedElicitationModes({ applyDefaults: true, url: {} }); |
| 49 | + expect(result.supportsFormMode).toBe(false); |
| 50 | + expect(result.supportsUrlMode).toBe(true); |
| 51 | + }); |
| 52 | + |
| 53 | + it('should support both modes when applyDefaults, form, and url are present', () => { |
| 54 | + const result = getSupportedElicitationModes({ applyDefaults: true, form: {}, url: {} }); |
| 55 | + expect(result.supportsFormMode).toBe(true); |
| 56 | + expect(result.supportsUrlMode).toBe(true); |
| 57 | + }); |
| 58 | + }); |
| 59 | +}); |
0 commit comments