Skip to content

Commit b6fc1e2

Browse files
author
Raphael Freitas
committed
Add tests for defaultStyles.js
1 parent 7a78b12 commit b6fc1e2

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright (c) 2017, Globo.com (https://github.com/globocom)
3+
*
4+
* License: MIT
5+
*/
6+
7+
/* eslint-env jest */
8+
import { defaultStylesForTest } from '../../../src/components/defaultStyles';
9+
10+
describe('defaultStyles', () => {
11+
describe('returns the style for each platform', () => {
12+
it('android', () => {
13+
expect(defaultStylesForTest('android')['code-block'].fontFamily).toBe('monospace');
14+
});
15+
16+
it('ios', () => {
17+
expect(defaultStylesForTest('ios')['code-block'].fontFamily).toBe('Courier New');
18+
});
19+
});
20+
});

src/components/defaultStyles.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
Platform,
1212
} from 'react-native';
1313

14-
const defaultStyles = StyleSheet.create({
14+
const defaultStyles = (PlatformOS: string): Object => StyleSheet.create({
1515
paragraph: {
1616
fontSize: 14,
1717
fontWeight: 'normal',
@@ -66,7 +66,7 @@ const defaultStyles = StyleSheet.create({
6666
},
6767
'code-block': {
6868
backgroundColor: '#cecece',
69-
fontFamily: Platform.OS === 'android' ? 'monospace' : 'Courier New',
69+
fontFamily: PlatformOS === 'android' ? 'monospace' : 'Courier New',
7070
padding: 16,
7171
},
7272
blockquote: {
@@ -77,4 +77,5 @@ const defaultStyles = StyleSheet.create({
7777
},
7878
});
7979

80-
export default defaultStyles;
80+
export { defaultStyles as defaultStylesForTest };
81+
export default defaultStyles(Platform.OS);

0 commit comments

Comments
 (0)