diff --git a/Libraries/Components/Switch/__tests__/Switch-test.js b/Libraries/Components/Switch/__tests__/Switch-test.js new file mode 100644 index 00000000000000..f7791bd151b534 --- /dev/null +++ b/Libraries/Components/Switch/__tests__/Switch-test.js @@ -0,0 +1,96 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @emails oncall+react_native + * @flow strict-local + */ + +import * as React from 'react'; + +import Switch from '../Switch'; +import View from '../../View/View'; +import {expectRendersMatchingSnapshot} from '../../../Utilities/ReactNativeTestTools'; + +describe('', () => { + it('should render as expected', () => { + expectRendersMatchingSnapshot( + 'Switch', + () => ( + + + + ), + () => { + jest.dontMock('../Switch'); + }, + ); + }); +}); + +describe('', () => { + it('should be disabled when disabled is true', () => { + expectRendersMatchingSnapshot( + 'Switch', + () => ( + + + + ), + () => { + jest.dontMock('../Switch'); + }, + ); + }); +}); + +describe('', () => { + it('should be disabled when disabled is true and accessibilityState is empty', () => { + expectRendersMatchingSnapshot( + 'Switch', + () => ( + + + + ), + () => { + jest.dontMock('../Switch'); + }, + ); + }); +}); + +describe('', () => { + it('should keep accessibilityState when disabled is true', () => { + expectRendersMatchingSnapshot( + 'Switch', + () => ( + + + + ), + () => { + jest.dontMock('../Switch'); + }, + ); + }); +}); + +describe('', () => { + it('should overwrite accessibilityState with value of disabled prop', () => { + expectRendersMatchingSnapshot( + 'Switch', + () => ( + + + + ), + () => { + jest.dontMock('../Switch'); + }, + ); + }); +});