Skip to content

Commit

Permalink
test: adds additional test cases to text and string widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
geotrev committed May 11, 2023
1 parent f2a927d commit 44f3d99
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/netlify-cms-widget-string/src/__tests__/string.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
12 changes: 12 additions & 0 deletions packages/netlify-cms-widget-text/src/__tests__/text.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

0 comments on commit 44f3d99

Please sign in to comment.