-
Notifications
You must be signed in to change notification settings - Fork 734
Automation gap - WOAUILIB-3704 #2902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
f8a6d14
dcd4112
f6dbf82
c12cb4b
9fa25a5
00d859a
faeeec7
2a198e0
fb955ab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,71 @@ | ||
import React from 'react'; | ||
import {render} from '@testing-library/react-native'; | ||
import View from '../../view'; | ||
import Text from '../index'; | ||
import {TextDriver} from '../Text.driver.new'; | ||
import {StyleSheet} from 'react-native'; | ||
|
||
const TEXT_ID = 'text_test_id'; | ||
const TEXT_CONTENT = 'text content'; | ||
|
||
function WrapperScreenWithText(textProps: {onPress?: jest.Mock} = {}) { | ||
const {onPress} = textProps; | ||
const Text = require('../../text').default; | ||
return ( | ||
<View> | ||
<Text testID={TEXT_ID} onPress={onPress}> | ||
{TEXT_CONTENT} | ||
</Text> | ||
</View> | ||
<Text testID={TEXT_ID} onPress={onPress}> | ||
{TEXT_CONTENT} | ||
</Text> | ||
); | ||
} | ||
|
||
const getDriver = (textProps: {onPress?: jest.Mock} = {}) => { | ||
const {onPress} = textProps; | ||
const renderTree = render(<WrapperScreenWithText onPress={onPress}/>); | ||
const textDriver = TextDriver({renderTree, testID: TEXT_ID}); | ||
return {renderTree, textDriver}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't think you need to return |
||
}; | ||
|
||
describe('Text', () => { | ||
it('should render Text Component', () => { | ||
const renderTree = render(<WrapperScreenWithText/>); | ||
const textDriver = TextDriver({renderTree, testID: TEXT_ID}); | ||
const {textDriver} = getDriver(); | ||
const content = textDriver.getText(); | ||
expect(content).toEqual(TEXT_CONTENT); | ||
}); | ||
|
||
describe('onPress', () => { | ||
it('should press the text, and run callback', () => { | ||
const onPressCallback = jest.fn(); | ||
const renderTree = render(<WrapperScreenWithText onPress={onPressCallback}/>); | ||
const textDriver = TextDriver({renderTree, testID: TEXT_ID}); | ||
|
||
const {textDriver} = getDriver({onPress: onPressCallback}); | ||
textDriver.press(); | ||
|
||
expect(onPressCallback).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it('should not be pressable if onPress prop is not supplied', () => { | ||
const renderTree = render(<WrapperScreenWithText/>); | ||
const textDriver = TextDriver({renderTree, testID: TEXT_ID}); | ||
const {textDriver} = getDriver(); | ||
expect(textDriver.hasOnPress()).toBeFalsy(); | ||
}); | ||
}); | ||
}); | ||
const setConstants = (isAndroid: boolean, isRTL: boolean) => { | ||
const {Constants} = require('../../../commons/new'); | ||
Constants.isAndroid = isAndroid; | ||
Constants.isIOS = !isAndroid; | ||
Constants.isRTL = isRTL; | ||
}; | ||
|
||
describe('Automation gap', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider adding tests for LTR as well There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For text? Or in general? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same tests but with LTR |
||
it('Should render text on right on rtl - Android', () => { | ||
jest.isolateModules(() => { | ||
setConstants(true, true); | ||
const {textDriver} = getDriver(); | ||
const textStyle = textDriver.getProps().style; | ||
expect(StyleSheet.flatten(textStyle).textAlign).toEqual('left'); | ||
}); | ||
}); | ||
it('Should render text on right on rtl - IOS', () => { | ||
jest.isolateModules(() => { | ||
setConstants(false, true); | ||
const {textDriver} = getDriver(); | ||
const textStyle = textDriver.getProps().style; | ||
expect(StyleSheet.flatten(textStyle).writingDirection).toEqual('rtl'); | ||
}); | ||
}); | ||
}); |
Uh oh!
There was an error while loading. Please reload this page.