From 44f3d99ad61b3bceb0d4e98cbc5aa0123b66c04a Mon Sep 17 00:00:00 2001 From: George Treviranus Date: Mon, 10 Oct 2022 14:01:03 -0500 Subject: [PATCH] test: adds additional test cases to text and string widgets --- .../src/__tests__/string.spec.js | 12 ++++++++++++ .../src/__tests__/text.spec.js | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/packages/netlify-cms-widget-string/src/__tests__/string.spec.js b/packages/netlify-cms-widget-string/src/__tests__/string.spec.js index 3744cac3d528..06172f55e6ab 100644 --- a/packages/netlify-cms-widget-string/src/__tests__/string.spec.js +++ b/packages/netlify-cms-widget-string/src/__tests__/string.spec.js @@ -69,4 +69,16 @@ describe('String widget', () => { expect(onChangeSpy).toBeCalledTimes(1); expect(onChangeSpy).toBeCalledWith(testValue); }); + + it('sets input value', () => { + const testValue = 'foo'; + const { input } = setup({ defaultValue: 'bar' }); + + fireEvent.focus(input); + fireEvent.change(input, { target: { value: testValue } }); + + jest.runAllTimers(); + + expect(input.value).toEqual(testValue); + }); }); diff --git a/packages/netlify-cms-widget-text/src/__tests__/text.spec.js b/packages/netlify-cms-widget-text/src/__tests__/text.spec.js index b1ff6888dd87..1d1106a00557 100644 --- a/packages/netlify-cms-widget-text/src/__tests__/text.spec.js +++ b/packages/netlify-cms-widget-text/src/__tests__/text.spec.js @@ -69,4 +69,16 @@ describe('String widget', () => { expect(onChangeSpy).toBeCalledTimes(1); expect(onChangeSpy).toBeCalledWith(testValue); }); + + it('sets input value', () => { + const testValue = 'foo'; + const { textarea } = setup({ defaultValue: 'bar' }); + + fireEvent.focus(textarea); + fireEvent.change(textarea, { target: { value: testValue } }); + + jest.runAllTimers(); + + expect(textarea.value).toEqual(testValue); + }); });