From adc50c3db667b685bb3caeaf1f1abf1d0e4298d7 Mon Sep 17 00:00:00 2001 From: Marliana Lara Date: Tue, 24 Nov 2020 15:21:53 -0500 Subject: [PATCH] Handle reverting falsy values that are not null or undefined --- .../screens/Setting/shared/SharedFields.jsx | 2 +- .../Setting/shared/SharedFields.test.jsx | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/awx/ui_next/src/screens/Setting/shared/SharedFields.jsx b/awx/ui_next/src/screens/Setting/shared/SharedFields.jsx index 13ec5dc11c5a..5681a91e56db 100644 --- a/awx/ui_next/src/screens/Setting/shared/SharedFields.jsx +++ b/awx/ui_next/src/screens/Setting/shared/SharedFields.jsx @@ -190,7 +190,7 @@ const InputField = withI18n()( return config ? ( { expect(wrapper.find('TextInputBase').prop('value')).toEqual('foo'); }); + test('InputField should revert to expected default value', async () => { + const wrapper = mountWithContexts( + + {() => ( + + )} + + ); + expect(wrapper.find('TextInputBase')).toHaveLength(1); + expect(wrapper.find('TextInputBase').prop('value')).toEqual(5); + await act(async () => { + wrapper.find('button[aria-label="Revert"]').invoke('onClick')(); + }); + wrapper.update(); + expect(wrapper.find('TextInputBase').prop('value')).toEqual(0); + }); + test('ObjectField renders the expected content', async () => { const wrapper = mountWithContexts(