diff --git a/Libraries/YellowBox/Data/YellowBoxCategory.js b/Libraries/YellowBox/Data/YellowBoxCategory.js
index 5e22fa96bdf710..b0c5984ce950ff 100644
--- a/Libraries/YellowBox/Data/YellowBoxCategory.js
+++ b/Libraries/YellowBox/Data/YellowBoxCategory.js
@@ -134,7 +134,7 @@ const YellowBoxCategory = {
0,
);
- if (lastOffset < content.length - 1) {
+ if (lastOffset < content.length) {
const lastPart = content.substr(lastOffset);
elements.push({lastPart});
}
diff --git a/Libraries/YellowBox/Data/__tests__/YellowBoxCategory-test.js b/Libraries/YellowBox/Data/__tests__/YellowBoxCategory-test.js
index 5c7ab61b409a0d..e835485ec1b566 100644
--- a/Libraries/YellowBox/Data/__tests__/YellowBoxCategory-test.js
+++ b/Libraries/YellowBox/Data/__tests__/YellowBoxCategory-test.js
@@ -97,4 +97,89 @@ describe('YellowBoxCategory', () => {
},
});
});
+
+ it('renders content with no substitutions', () => {
+ expect(
+ YellowBoxCategory.render(
+ {content: 'A', substitutions: []},
+ {fontWeight: 'bold'},
+ ),
+ ).toMatchSnapshot();
+ });
+
+ it('renders a single substitution', () => {
+ expect(
+ YellowBoxCategory.render(
+ {
+ content: '"A"',
+ substitutions: [
+ {
+ length: 3,
+ offset: 0,
+ },
+ ],
+ },
+ {fontWeight: 'bold'},
+ ),
+ ).toMatchSnapshot();
+ });
+
+ it('renders multiple substitutions', () => {
+ expect(
+ YellowBoxCategory.render(
+ {
+ content: '"A" "B" "C"',
+ substitutions: [
+ {
+ length: 3,
+ offset: 0,
+ },
+ {
+ length: 3,
+ offset: 4,
+ },
+ {
+ length: 3,
+ offset: 8,
+ },
+ ],
+ },
+ {fontWeight: 'bold'},
+ ),
+ ).toMatchSnapshot();
+ });
+
+ it('renders substitutions with leading content', () => {
+ expect(
+ YellowBoxCategory.render(
+ {
+ content: '!"A"',
+ substitutions: [
+ {
+ length: 3,
+ offset: 1,
+ },
+ ],
+ },
+ {fontWeight: 'bold'},
+ ),
+ ).toMatchSnapshot();
+ });
+
+ it('renders substitutions with trailing content', () => {
+ expect(
+ YellowBoxCategory.render(
+ {
+ content: '"A"!',
+ substitutions: [
+ {
+ length: 3,
+ offset: 0,
+ },
+ ],
+ },
+ {fontWeight: 'bold'},
+ ),
+ ).toMatchSnapshot();
+ });
});
diff --git a/Libraries/YellowBox/Data/__tests__/__snapshots__/YellowBoxCategory-test.js.snap b/Libraries/YellowBox/Data/__tests__/__snapshots__/YellowBoxCategory-test.js.snap
new file mode 100644
index 00000000000000..ee88875c3717c9
--- /dev/null
+++ b/Libraries/YellowBox/Data/__tests__/__snapshots__/YellowBoxCategory-test.js.snap
@@ -0,0 +1,95 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`YellowBoxCategory renders a single substitution 1`] = `
+Array [
+
+ "A"
+ ,
+]
+`;
+
+exports[`YellowBoxCategory renders content with no substitutions 1`] = `
+Array [
+
+ A
+ ,
+]
+`;
+
+exports[`YellowBoxCategory renders multiple substitutions 1`] = `
+Array [
+
+ "A"
+ ,
+
+
+ ,
+
+ "B"
+ ,
+
+
+ ,
+
+ "C"
+ ,
+]
+`;
+
+exports[`YellowBoxCategory renders substitutions with leading content 1`] = `
+Array [
+
+ !
+ ,
+
+ "A"
+ ,
+]
+`;
+
+exports[`YellowBoxCategory renders substitutions with trailing content 1`] = `
+Array [
+
+ "A"
+ ,
+
+ !
+ ,
+]
+`;