Skip to content

Commit 8d3d957

Browse files
ethansharadids1221
authored andcommitted
Refactor HintDriver to allow optional style flattening in tests (#3502)
1 parent 329bda5 commit 8d3d957

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/components/hint/__tests__/index.spec.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ describe('Hint Screen component test', () => {
4747
const renderTree = render(<TestCase visible/>);
4848
const driver = HintDriver({renderTree, testID: HINT_TEST_ID});
4949
const hintBubble = await driver.getHintBubble();
50-
expect(hintBubble.getStyle().backgroundColor).toBe(expectedColor);
50+
expect(hintBubble.getStyle(true).backgroundColor).toBe(expectedColor);
5151
});
5252

5353
it('Should color hint bubble with provided color prop', async () => {
5454
const renderTree = render(<TestCase visible color={Colors.white}/>);
5555
const driver = HintDriver({renderTree, testID: HINT_TEST_ID});
5656
const hintBubble = await driver.getHintBubble();
57-
expect(hintBubble.getStyle().backgroundColor).toBe(Colors.white);
57+
expect(hintBubble.getStyle(true).backgroundColor).toBe(Colors.white);
5858
});
5959

6060
it('Should modal be not visible when hint is not visible', async () => {

src/components/view/View.driver.new.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import {useComponentDriver, ComponentProps} from '../../testkit/new/Component.dr
44
export const ViewDriver = (props: ComponentProps) => {
55
const driver = useComponentDriver(props);
66

7-
const getStyle = () => {
8-
return StyleSheet.flatten(driver.getElement().props.style);
7+
const getStyle = (flatten = false) => {
8+
const style = driver.getElement().props.style;
9+
return flatten ? StyleSheet.flatten(style) : style;
910
};
1011
return {...driver, getStyle};
1112
};

0 commit comments

Comments
 (0)