From 25b35a09b9a6da767b9d253dc4bd4daa38a7f9bd Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Thu, 31 Mar 2016 17:01:11 +0100 Subject: [PATCH] Clean up some redundancy in the MessagePanel test --- .../structures/MessagePanel-test.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/test/components/structures/MessagePanel-test.js b/test/components/structures/MessagePanel-test.js index 3e984e8134..f775388617 100644 --- a/test/components/structures/MessagePanel-test.js +++ b/test/components/structures/MessagePanel-test.js @@ -91,11 +91,13 @@ describe('MessagePanel', function () { var tiles = TestUtils.scryRenderedComponentsWithType( mp, sdk.getComponent('rooms.EventTile')); + var tileContainers = tiles.map(function (t) { + return ReactDOM.findDOMNode(t).parentNode; + }); // find the
  • which wraps the read marker var rm = TestUtils.findRenderedDOMComponentWithClass(mp, 'mx_RoomView_myReadMarker_container'); - var eventContainer = ReactDOM.findDOMNode(tiles[4]).parentNode; - expect(rm.previousSibling).toEqual(eventContainer); + expect(rm.previousSibling).toEqual(tileContainers[4]); // now move the RM mp = ReactDOM.render( @@ -108,18 +110,11 @@ describe('MessagePanel', function () { expect(found.length).toEqual(2); // the first should be the ghost - var ghost = found[0]; - eventContainer = ReactDOM.findDOMNode(tiles[4]).parentNode; - expect(ghost.previousSibling).toEqual(eventContainer); - var hr = ghost.children[0]; - - // the first should be the ghost - eventContainer = ReactDOM.findDOMNode(tiles[4]).parentNode; - expect(found[0].previousSibling).toEqual(eventContainer); + expect(found[0].previousSibling).toEqual(tileContainers[4]); + var hr = found[0].children[0]; // the second should be the real thing - eventContainer = ReactDOM.findDOMNode(tiles[4]).parentNode; - expect(ghost.previousSibling).toEqual(eventContainer); + expect(found[1].previousSibling).toEqual(tileContainers[6]); // advance the clock, and then let the browser run an animation frame, // to let the animation start