Skip to content

Commit

Permalink
Tweak syntax of accessing '_instance' in DraftEditor test (#1247)
Browse files Browse the repository at this point in the history
**what is the change?:**
We either check for the 'getEditorKey' method on the
'renderedComponent._instance' or the
'renderedComponent._instance._instance'

**why make this change?:**
Internally we are using a different variation of the 'shallowRenderer'
and this test needs to run internally at Facebook as well as on Github.

This is not an ideal solution, but we can continue improving this test
once cleaning up the inconsistencies between Facebook and Github.

**test plan:**
`jest src/component/base/__tests__/DraftEditor.react-test.js`

**issue:**
facebookarchive/draft-js#1244
  • Loading branch information
midas19910709 committed Jun 15, 2017
1 parent 76083d3 commit 678b9b0
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/component/base/__tests__/DraftEditor.react-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,15 @@ describe('DraftEditor.react', () => {
shallow.render(
<DraftEditor />,
);

var key = shallow._instance._instance.getEditorKey();

// internally at Facebook we use a newer version of the shallowRenderer
// which has a different level of wrapping of the '_instance'
// long term we should rewrite this test to not depend on private
// properties
var getEditorKey =
shallow._instance.getEditorKey
|| shallow._instance._instance.getEditorKey;
var key = getEditorKey();
expect(typeof key).toBe('string');
expect(key.length).toBeGreaterThanOrEqual(4);
});
Expand All @@ -44,8 +51,15 @@ describe('DraftEditor.react', () => {
shallow.render(
<DraftEditor editorKey="hash" />,
);

var key = shallow._instance._instance.getEditorKey();

// internally at Facebook we use a newer version of the shallowRenderer
// which has a different level of wrapping of the '_instance'
// long term we should rewrite this test to not depend on private
// properties
var getEditorKey =
shallow._instance.getEditorKey
|| shallow._instance._instance.getEditorKey;
var key = getEditorKey();
expect(key).toBe('hash');
});
});
Expand Down

0 comments on commit 678b9b0

Please sign in to comment.