forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Taken from my previous pr https://github.com/facebook/react-native/pull/31199/files
- Loading branch information
1 parent
b3a90cd
commit 94a6a7f
Showing
1 changed file
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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('<Switch />', () => { | ||
it('should render as expected', () => { | ||
expectRendersMatchingSnapshot( | ||
'Switch', | ||
() => ( | ||
<Switch> | ||
<View /> | ||
</Switch> | ||
), | ||
() => { | ||
jest.dontMock('../Switch'); | ||
}, | ||
); | ||
}); | ||
}); | ||
|
||
describe('<Switch disabled={true} />', () => { | ||
it('should be disabled when disabled is true', () => { | ||
expectRendersMatchingSnapshot( | ||
'Switch', | ||
() => ( | ||
<Switch disabled={true}> | ||
<View /> | ||
</Switch> | ||
), | ||
() => { | ||
jest.dontMock('../Switch'); | ||
}, | ||
); | ||
}); | ||
}); | ||
|
||
describe('<Switch disabled={true} accessibilityState={{}} />', () => { | ||
it('should be disabled when disabled is true and accessibilityState is empty', () => { | ||
expectRendersMatchingSnapshot( | ||
'Switch', | ||
() => ( | ||
<Switch disabled={true} accessibilityState={{}}> | ||
<View /> | ||
</Switch> | ||
), | ||
() => { | ||
jest.dontMock('../Switch'); | ||
}, | ||
); | ||
}); | ||
}); | ||
|
||
describe('<Switch disabled={true} accessibilityState={{checked: true}} />', () => { | ||
it('should keep accessibilityState when disabled is true', () => { | ||
expectRendersMatchingSnapshot( | ||
'Switch', | ||
() => ( | ||
<Switch disabled={true} accessibilityState={{checked: true}}> | ||
<View /> | ||
</Switch> | ||
), | ||
() => { | ||
jest.dontMock('../Switch'); | ||
}, | ||
); | ||
}); | ||
}); | ||
|
||
describe('<Switch disabled={true} accessibilityState={{disabled: false}} />', () => { | ||
it('should overwrite accessibilityState with value of disabled prop', () => { | ||
expectRendersMatchingSnapshot( | ||
'Switch', | ||
() => ( | ||
<Switch disabled={true} accessibilityState={{disabled: false}}> | ||
<View /> | ||
</Switch> | ||
), | ||
() => { | ||
jest.dontMock('../Switch'); | ||
}, | ||
); | ||
}); | ||
}); |