diff --git a/.changeset/curvy-owls-joke.md b/.changeset/curvy-owls-joke.md deleted file mode 100644 index 3ec6bf3e9..000000000 --- a/.changeset/curvy-owls-joke.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -"@getodk/common": patch -"@getodk/scenario": patch -"@getodk/web-forms": minor ---- - -- Partial support for `` (basic horizontal and vertical sliders) -- Partial support for `` bind/value types (string, int, decimal) -- Partial support for ` values are written in option order (consistent with JavaRosa, also tested elsewhere with strings)', - }, - { selectValues: [], expectedValue: [] }, - ])('setValue ($selectValues)', ({ selectValues, expectedValue, reason }) => { - const selectValuesDescription = JSON.stringify(selectValues.map(String)); - const expectedValueDescription = JSON.stringify(expectedValue.map(String)); - const reasonDescription = reason == null ? '' : `(${reason})`; - const description = - `sets ${selectValuesDescription}, resulting in value ${expectedValueDescription} ${reasonDescription}`.trim(); - - it(description, () => { - scenario.proposed_answerTypedSelect('/root/int-value', 'int', selectValues); - answer = getTypedSelectNodeAnswer('/root/int-value', 'int'); - - expectTypeOf(answer.value).toEqualTypeOf(); - - expect(answer.value).toEqual(expectedValue); - - const expectedStringValue = expectedValue.map(String).join(' '); - - expect(answer.stringValue).toBe(expectedStringValue); - }); - }); - - interface SetIntSelectErrorCase { - readonly selectValues: readonly bigint[]; - } - - // TODO: unsure if there's anything to test here! The values won't be - // set because they're not available in the select's `valueOptions`. - describe.skip.each([ - { selectValues: [-2_147_483_649n] }, - { selectValues: [2_147_483_648n] }, - { selectValues: [-2_147_483_649n, 2_147_483_648n] }, - { selectValues: [2_147_483_649n, -2_147_483_648n] }, - ])('integer value out of specified bounds ($selectType)', ({ selectValues }) => { - const selectValuesDescription = JSON.stringify(selectValues.map(String)); - - it(`fails to set ${selectValuesDescription}`, () => { - let caught: unknown; - - try { - scenario.proposed_answerTypedSelect('/root/int-value', 'int', selectValues); - answer = getTypedSelectNodeAnswer('/root/int-value', 'int'); - } catch (error) { - caught = error; - } - - expect(caught, `Value was set to ${answer.stringValue}`).toBeInstanceOf(Error); - }); - }); - }); - }); - - describe('type="decimal"', () => { - let answer: SelectNodeAnswer<'decimal'>; - - beforeEach(() => { - answer = getTypedSelectNodeAnswer('/root/decimal-value', 'decimal'); - }); - - it('has a runtime value which is an array of a single number value', () => { - expect(answer.value).toBeInstanceOf(Array); - expect(answer.value.length).toBe(1); - expect(answer.value[0]).toBeTypeOf('number'); - }); - - it('has a readonly number[] static type', () => { - expectTypeOf(answer.value).toEqualTypeOf(); - }); - - it('has a number populated value', () => { - expect(answer.value).toEqual([45.67]); - }); - - it('has an empty array blank value', () => { - scenario.answer(selectRelevancePath, 'no'); - answer = getTypedSelectNodeAnswer('/root/decimal-value', 'decimal'); - expect(answer.value).toEqual([]); - }); - - describe('setting decimal values', () => { - interface SetDecimalSelectValueCase { - readonly selectValues: readonly number[]; - readonly expectedValue: readonly number[]; - readonly reason?: string; - } - - it.each([ - { selectValues: [89], expectedValue: [89] }, - { selectValues: [10], expectedValue: [10] }, - { selectValues: [45.67, 23.4], expectedValue: [45.67, 23.4] }, - { - selectValues: [23.4, 45.67], - expectedValue: [45.67, 23.4], - reason: - '