-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from khevamann/invalid_regex
Invalid Regex
- Loading branch information
Showing
5 changed files
with
90 additions
and
2 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
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
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,31 @@ | ||
import * as React from 'react' | ||
import { CreateResponsiveStyle, DEVICE_SIZES } from '../src' | ||
import { Text, View } from 'react-native' | ||
|
||
export default function OverwriteStyle() { | ||
const { styles } = useStyles() | ||
|
||
return ( | ||
<View> | ||
<Text style={styles('text')}>Open up App.tsx to start working on your app!</Text> | ||
</View> | ||
) | ||
} | ||
|
||
const useStyles = CreateResponsiveStyle( | ||
{ | ||
text: { | ||
fontSize: 40, | ||
}, | ||
textBold: { | ||
fontWeight: '700', | ||
}, | ||
}, | ||
{ | ||
[DEVICE_SIZES.MEDIUM_DEVICE]: { | ||
textBold: { | ||
fontWeight: '700', | ||
}, | ||
}, | ||
}, | ||
) |
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,29 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`additional tests for specific cases tests that regex does not include extra classes: medium 1`] = ` | ||
<View> | ||
<Text | ||
style={ | ||
Object { | ||
"fontSize": 40, | ||
} | ||
} | ||
> | ||
Open up App.tsx to start working on your app! | ||
</Text> | ||
</View> | ||
`; | ||
|
||
exports[`additional tests for specific cases tests that regex only picks up the exact class specified: small 1`] = ` | ||
<View> | ||
<Text | ||
style={ | ||
Object { | ||
"fontSize": 40, | ||
} | ||
} | ||
> | ||
Open up App.tsx to start working on your app! | ||
</Text> | ||
</View> | ||
`; |
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,28 @@ | ||
import * as renderer from 'react-test-renderer' | ||
import OverwriteStyle from './OverwriteStyle' | ||
import * as React from 'react' | ||
import { cleanup } from '@testing-library/react-native' | ||
import { ScaledSize } from 'react-native' | ||
|
||
afterEach(cleanup) | ||
|
||
const mockDimensions = ({ width }: Pick<ScaledSize, 'width'>) => { | ||
jest.resetModules() | ||
jest.doMock('react-native/Libraries/Utilities/Dimensions', () => ({ | ||
get: jest.fn().mockReturnValue({ width }), | ||
addEventListener: jest.fn(), | ||
})) | ||
} | ||
|
||
describe('additional tests for specific cases', () => { | ||
test('tests that regex only picks up the exact class specified', () => { | ||
mockDimensions({ width: 470 }) | ||
const tree = renderer.create(<OverwriteStyle />).toJSON() | ||
expect(tree).toMatchSnapshot('small') | ||
}) | ||
test('tests that regex does not include extra classes', () => { | ||
mockDimensions({ width: 770 }) | ||
const tree = renderer.create(<OverwriteStyle />).toJSON() | ||
expect(tree).toMatchSnapshot('medium') | ||
}) | ||
}) |