Skip to content

Commit cd3900f

Browse files
Canedoraphaelpor
authored andcommitted
support to new text (ios) implementation on react native 0.54+ (#39)
* support to new text (ios) implementation on react native 0.54+ * add more coverage
1 parent b0af6b2 commit cd3900f

File tree

11 files changed

+1949
-1269
lines changed

11 files changed

+1949
-1269
lines changed

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,26 @@
2424
"react-native": ">=0.49.3"
2525
},
2626
"dependencies": {
27-
"stringz": "0.4.0"
27+
"stringz": "1.0.0"
2828
},
2929
"devDependencies": {
3030
"babel-eslint": "8.2.2",
31-
"babel-jest": "22.4.1",
31+
"babel-jest": "22.4.3",
3232
"babel-preset-react-native": "4.0.0",
3333
"coveralls": "3.0.0",
34-
"eslint": "4.18.1",
34+
"eslint": "4.19.1",
3535
"eslint-config-airbnb": "16.1.0",
3636
"eslint-plugin-flowtype": "2.46.1",
37-
"eslint-plugin-import": "2.9.0",
37+
"eslint-plugin-import": "2.10.0",
3838
"eslint-plugin-jsx-a11y": "6.0.3",
3939
"eslint-plugin-react": "7.7.0",
4040
"eslint-plugin-react-native": "3.2.1",
41-
"flow-bin": "0.66.0",
42-
"jest": "22.4.2",
43-
"react": "16.2.0",
44-
"react-dom": "16.2.0",
45-
"react-native": "0.53.3",
46-
"react-test-renderer": "16.2.0"
41+
"flow-bin": "0.69.0",
42+
"jest": "22.4.3",
43+
"react": "16.3.1",
44+
"react-dom": "16.3.1",
45+
"react-native": "0.55.2",
46+
"react-test-renderer": "16.3.1"
4747
},
4848
"jest": {
4949
"preset": "react-native",

sample/__tests__/components/__snapshots__/TextStyled.test.js.snap

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@ exports[`renders correctly with customStyles and multiple types 1`] = `
77
ellipsizeMode="tail"
88
style={
99
Array [
10-
Object {
11-
"fontStyle": "italic",
12-
"fontWeight": "bold",
13-
},
14-
Object {
15-
"fontStyle": "italic",
16-
"fontWeight": "bold",
17-
},
10+
Array [
11+
Object {
12+
"fontStyle": "italic",
13+
"fontWeight": "bold",
14+
},
15+
Object {
16+
"fontStyle": "italic",
17+
"fontWeight": "bold",
18+
},
19+
],
20+
undefined,
1821
]
1922
}
2023
>
@@ -29,12 +32,15 @@ exports[`renders correctly with customStyles and single type 1`] = `
2932
ellipsizeMode="tail"
3033
style={
3134
Array [
32-
Object {
33-
"fontWeight": "bold",
34-
},
35-
Object {
36-
"fontWeight": "bold",
37-
},
35+
Array [
36+
Object {
37+
"fontWeight": "bold",
38+
},
39+
Object {
40+
"fontWeight": "bold",
41+
},
42+
],
43+
undefined,
3844
]
3945
}
4046
>
@@ -50,6 +56,9 @@ exports[`renders correctly with onPress 1`] = `
5056
onPress={[Function]}
5157
style={
5258
Array [
59+
Array [
60+
undefined,
61+
],
5362
undefined,
5463
]
5564
}
@@ -65,6 +74,9 @@ exports[`renders correctly without onPress 1`] = `
6574
ellipsizeMode="tail"
6675
style={
6776
Array [
77+
Array [
78+
undefined,
79+
],
6880
undefined,
6981
]
7082
}

sample/__tests__/loadAttributes.test.js

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,87 @@ it('have correct length with multiple inlineStyles and text with substring witho
182182
expect(result).toHaveLength(2);
183183
expect(result[0].props.children).toBe(params.text);
184184
});
185+
186+
it('have inlineStyles with substring and type is given', () => {
187+
const params = {
188+
text: 'Hello World Hello World Hello World',
189+
inlineStyles: [{
190+
offset: 300,
191+
length: 2,
192+
style: 'BOLD',
193+
}],
194+
entityMap: {},
195+
entityRanges: [],
196+
type: 'unstyled',
197+
};
198+
const result = loadAttributes(params);
199+
expect(result).toHaveLength(2);
200+
expect(result[0].props.children).toBe(params.text);
201+
});
202+
203+
204+
it('have inlineStyles with substring and type is given with proper customStyles to that type', () => {
205+
const params = {
206+
text: 'Hello World Hello World Hello World',
207+
inlineStyles: [{
208+
offset: 300,
209+
length: 2,
210+
style: 'BOLD',
211+
}],
212+
entityMap: {},
213+
entityRanges: [],
214+
type: 'unstyled',
215+
customStyles: {
216+
unstyled: {
217+
lineHeight: 30,
218+
},
219+
},
220+
};
221+
const result = loadAttributes(params);
222+
expect(result).toHaveLength(2);
223+
expect(result[0].props.children).toBe(params.text);
224+
});
225+
226+
it('have inlineStyles with substring and type is given without proper customStyles to that type', () => {
227+
const params = {
228+
text: 'Hello World Hello World Hello World',
229+
inlineStyles: [{
230+
offset: 300,
231+
length: 2,
232+
style: 'BOLD',
233+
}],
234+
entityMap: {},
235+
entityRanges: [],
236+
type: 'unstyled',
237+
customStyles: {
238+
other: {
239+
lineHeight: 30,
240+
},
241+
},
242+
};
243+
const result = loadAttributes(params);
244+
expect(result).toHaveLength(2);
245+
expect(result[0].props.children).toBe(params.text);
246+
});
247+
248+
it('have inlineStyles with substring and type is given without lineHeight customStyles to that type', () => {
249+
const params = {
250+
text: 'Hello World Hello World Hello World',
251+
inlineStyles: [{
252+
offset: 300,
253+
length: 2,
254+
style: 'BOLD',
255+
}],
256+
entityMap: {},
257+
entityRanges: [],
258+
type: 'unstyled',
259+
customStyles: {
260+
unstyled: {
261+
fontSize: 30,
262+
},
263+
},
264+
};
265+
const result = loadAttributes(params);
266+
expect(result).toHaveLength(2);
267+
expect(result[0].props.children).toBe(params.text);
268+
});

sample/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
"watch-index": "sync-files --watch ../index.js react-native-draftjs-render/index.js"
1212
},
1313
"dependencies": {
14-
"react": "16.2.0",
15-
"react-native": "0.53.3",
16-
"stringz": "0.4.0"
14+
"react": "16.3.1",
15+
"react-native": "0.55.2",
16+
"stringz": "1.0.0"
1717
},
1818
"devDependencies": {
19-
"babel-jest": "22.4.1",
19+
"babel-jest": "22.4.3",
2020
"babel-preset-react-native": "4.0.0",
21-
"jest": "22.4.2",
22-
"react-test-renderer": "16.2.0",
21+
"jest": "22.4.3",
22+
"react-test-renderer": "16.3.1",
2323
"sync-files": "1.0.3"
2424
},
2525
"jest": {

sample/src/resourceMock.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
},
8282
{
8383
"key": "5r8641253",
84-
"text": "Etiam ultricies nisi vel augue.",
84+
"text": "Etiam ultricies nisi vel augue vel augue vel augue.",
8585
"type": "unstyled",
8686
"depth": 0,
8787
"inlineStyleRanges": [

0 commit comments

Comments
 (0)