You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-07-30 02:21:17 +03:00
Run eslint --fix
Fixing 1000s of lint issues. Some rules cannot be `--fix`ed but this goes some way to linting the entire codebase.
This commit is contained in:
@ -14,22 +14,22 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
var React = require('react');
|
||||
var ReactDOM = require("react-dom");
|
||||
var TestUtils = require('react-addons-test-utils');
|
||||
var expect = require('expect');
|
||||
const React = require('react');
|
||||
const ReactDOM = require("react-dom");
|
||||
const TestUtils = require('react-addons-test-utils');
|
||||
const expect = require('expect');
|
||||
import sinon from 'sinon';
|
||||
|
||||
var sdk = require('matrix-react-sdk');
|
||||
const sdk = require('matrix-react-sdk');
|
||||
|
||||
var MessagePanel = sdk.getComponent('structures.MessagePanel');
|
||||
const MessagePanel = sdk.getComponent('structures.MessagePanel');
|
||||
import UserSettingsStore from '../../../src/UserSettingsStore';
|
||||
import MatrixClientPeg from '../../../src/MatrixClientPeg';
|
||||
|
||||
var test_utils = require('test-utils');
|
||||
var mockclock = require('mock-clock');
|
||||
const test_utils = require('test-utils');
|
||||
const mockclock = require('mock-clock');
|
||||
|
||||
var client;
|
||||
let client;
|
||||
|
||||
// wrap MessagePanel with a component which provides the MatrixClient in the context.
|
||||
const WrappedMessagePanel = React.createClass({
|
||||
@ -48,11 +48,11 @@ const WrappedMessagePanel = React.createClass({
|
||||
},
|
||||
});
|
||||
|
||||
describe('MessagePanel', function () {
|
||||
var clock = mockclock.clock();
|
||||
var realSetTimeout = window.setTimeout;
|
||||
var events = mkEvents();
|
||||
var sandbox = null;
|
||||
describe('MessagePanel', function() {
|
||||
const clock = mockclock.clock();
|
||||
const realSetTimeout = window.setTimeout;
|
||||
const events = mkEvents();
|
||||
let sandbox = null;
|
||||
|
||||
beforeEach(function() {
|
||||
test_utils.beforeEach(this);
|
||||
@ -68,9 +68,9 @@ describe('MessagePanel', function () {
|
||||
});
|
||||
|
||||
function mkEvents() {
|
||||
var events = [];
|
||||
var ts0 = Date.now();
|
||||
for (var i = 0; i < 10; i++) {
|
||||
const events = [];
|
||||
const ts0 = Date.now();
|
||||
for (let i = 0; i < 10; i++) {
|
||||
events.push(test_utils.mkMessage(
|
||||
{
|
||||
event: true, room: "!room:id", user: "@user:id",
|
||||
@ -81,30 +81,30 @@ describe('MessagePanel', function () {
|
||||
}
|
||||
|
||||
it('should show the events', function() {
|
||||
var res = TestUtils.renderIntoDocument(
|
||||
<WrappedMessagePanel className="cls" events={events} />
|
||||
const res = TestUtils.renderIntoDocument(
|
||||
<WrappedMessagePanel className="cls" events={events} />,
|
||||
);
|
||||
|
||||
// just check we have the right number of tiles for now
|
||||
var tiles = TestUtils.scryRenderedComponentsWithType(
|
||||
const tiles = TestUtils.scryRenderedComponentsWithType(
|
||||
res, sdk.getComponent('rooms.EventTile'));
|
||||
expect(tiles.length).toEqual(10);
|
||||
});
|
||||
|
||||
it('should show the read-marker in the right place', function() {
|
||||
var res = TestUtils.renderIntoDocument(
|
||||
const res = TestUtils.renderIntoDocument(
|
||||
<WrappedMessagePanel className="cls" events={events} readMarkerEventId={events[4].getId()}
|
||||
readMarkerVisible={true} />
|
||||
readMarkerVisible={true} />,
|
||||
);
|
||||
|
||||
var tiles = TestUtils.scryRenderedComponentsWithType(
|
||||
const tiles = TestUtils.scryRenderedComponentsWithType(
|
||||
res, sdk.getComponent('rooms.EventTile'));
|
||||
|
||||
// find the <li> which wraps the read marker
|
||||
var rm = TestUtils.findRenderedDOMComponentWithClass(res, 'mx_RoomView_myReadMarker_container');
|
||||
const rm = TestUtils.findRenderedDOMComponentWithClass(res, 'mx_RoomView_myReadMarker_container');
|
||||
|
||||
// it should follow the <li> which wraps the event tile for event 4
|
||||
var eventContainer = ReactDOM.findDOMNode(tiles[4]).parentNode;
|
||||
const eventContainer = ReactDOM.findDOMNode(tiles[4]).parentNode;
|
||||
expect(rm.previousSibling).toEqual(eventContainer);
|
||||
});
|
||||
|
||||
@ -113,22 +113,22 @@ describe('MessagePanel', function () {
|
||||
clock.install();
|
||||
clock.mockDate();
|
||||
|
||||
var parentDiv = document.createElement('div');
|
||||
const parentDiv = document.createElement('div');
|
||||
|
||||
// first render with the RM in one place
|
||||
var mp = ReactDOM.render(
|
||||
let mp = ReactDOM.render(
|
||||
<WrappedMessagePanel className="cls" events={events} readMarkerEventId={events[4].getId()}
|
||||
readMarkerVisible={true}
|
||||
/>, parentDiv);
|
||||
|
||||
var tiles = TestUtils.scryRenderedComponentsWithType(
|
||||
const tiles = TestUtils.scryRenderedComponentsWithType(
|
||||
mp, sdk.getComponent('rooms.EventTile'));
|
||||
var tileContainers = tiles.map(function (t) {
|
||||
const tileContainers = tiles.map(function(t) {
|
||||
return ReactDOM.findDOMNode(t).parentNode;
|
||||
});
|
||||
|
||||
// find the <li> which wraps the read marker
|
||||
var rm = TestUtils.findRenderedDOMComponentWithClass(mp, 'mx_RoomView_myReadMarker_container');
|
||||
const rm = TestUtils.findRenderedDOMComponentWithClass(mp, 'mx_RoomView_myReadMarker_container');
|
||||
expect(rm.previousSibling).toEqual(tileContainers[4]);
|
||||
|
||||
// now move the RM
|
||||
@ -138,12 +138,12 @@ describe('MessagePanel', function () {
|
||||
/>, parentDiv);
|
||||
|
||||
// now there should be two RM containers
|
||||
var found = TestUtils.scryRenderedDOMComponentsWithClass(mp, 'mx_RoomView_myReadMarker_container');
|
||||
const found = TestUtils.scryRenderedDOMComponentsWithClass(mp, 'mx_RoomView_myReadMarker_container');
|
||||
expect(found.length).toEqual(2);
|
||||
|
||||
// the first should be the ghost
|
||||
expect(found[0].previousSibling).toEqual(tileContainers[4]);
|
||||
var hr = found[0].children[0];
|
||||
const hr = found[0].children[0];
|
||||
|
||||
// the second should be the real thing
|
||||
expect(found[1].previousSibling).toEqual(tileContainers[6]);
|
||||
@ -164,17 +164,17 @@ describe('MessagePanel', function () {
|
||||
});
|
||||
|
||||
it('shows only one ghost when the RM moves twice', function() {
|
||||
var parentDiv = document.createElement('div');
|
||||
const parentDiv = document.createElement('div');
|
||||
|
||||
// first render with the RM in one place
|
||||
var mp = ReactDOM.render(
|
||||
let mp = ReactDOM.render(
|
||||
<WrappedMessagePanel className="cls" events={events} readMarkerEventId={events[4].getId()}
|
||||
readMarkerVisible={true}
|
||||
/>, parentDiv);
|
||||
|
||||
var tiles = TestUtils.scryRenderedComponentsWithType(
|
||||
const tiles = TestUtils.scryRenderedComponentsWithType(
|
||||
mp, sdk.getComponent('rooms.EventTile'));
|
||||
var tileContainers = tiles.map(function (t) {
|
||||
const tileContainers = tiles.map(function(t) {
|
||||
return ReactDOM.findDOMNode(t).parentNode;
|
||||
});
|
||||
|
||||
@ -185,7 +185,7 @@ describe('MessagePanel', function () {
|
||||
/>, parentDiv);
|
||||
|
||||
// now there should be two RM containers
|
||||
var found = TestUtils.scryRenderedDOMComponentsWithClass(mp, 'mx_RoomView_myReadMarker_container');
|
||||
let found = TestUtils.scryRenderedDOMComponentsWithClass(mp, 'mx_RoomView_myReadMarker_container');
|
||||
expect(found.length).toEqual(2);
|
||||
|
||||
// the first should be the ghost
|
||||
|
@ -14,18 +14,18 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
var React = require('react');
|
||||
var ReactDOM = require("react-dom");
|
||||
var ReactTestUtils = require('react-addons-test-utils');
|
||||
var expect = require('expect');
|
||||
const React = require('react');
|
||||
const ReactDOM = require("react-dom");
|
||||
const ReactTestUtils = require('react-addons-test-utils');
|
||||
const expect = require('expect');
|
||||
import Promise from 'bluebird';
|
||||
|
||||
var sdk = require('matrix-react-sdk');
|
||||
const sdk = require('matrix-react-sdk');
|
||||
|
||||
var ScrollPanel = sdk.getComponent('structures.ScrollPanel');
|
||||
var test_utils = require('test-utils');
|
||||
const ScrollPanel = sdk.getComponent('structures.ScrollPanel');
|
||||
const test_utils = require('test-utils');
|
||||
|
||||
var Tester = React.createClass({
|
||||
const Tester = React.createClass({
|
||||
getInitialState: function() {
|
||||
return {
|
||||
tileKeys: [],
|
||||
@ -43,18 +43,18 @@ var Tester = React.createClass({
|
||||
},
|
||||
|
||||
_onFillRequest: function(back) {
|
||||
var dir = back ? 'b': 'f';
|
||||
const dir = back ? 'b': 'f';
|
||||
console.log("FillRequest: " + dir);
|
||||
this.fillCounts[dir]++;
|
||||
|
||||
var handler = this._fillHandlers[dir];
|
||||
var defer = this._fillDefers[dir];
|
||||
const handler = this._fillHandlers[dir];
|
||||
const defer = this._fillDefers[dir];
|
||||
|
||||
// don't use the same handler twice
|
||||
this._fillHandlers[dir] = null;
|
||||
this._fillDefers[dir] = null;
|
||||
|
||||
var res;
|
||||
let res;
|
||||
if (handler) {
|
||||
res = handler();
|
||||
} else {
|
||||
@ -74,17 +74,17 @@ var Tester = React.createClass({
|
||||
/* returns a promise which will resolve when the fill happens */
|
||||
awaitFill: function(dir) {
|
||||
console.log("ScrollPanel Tester: awaiting " + dir + " fill");
|
||||
var defer = Promise.defer();
|
||||
const defer = Promise.defer();
|
||||
this._fillDefers[dir] = defer;
|
||||
return defer.promise;
|
||||
},
|
||||
|
||||
_onScroll: function(ev) {
|
||||
var st = ev.target.scrollTop;
|
||||
const st = ev.target.scrollTop;
|
||||
console.log("ScrollPanel Tester: scroll event; scrollTop: " + st);
|
||||
this.lastScrollEvent = st;
|
||||
|
||||
var d = this._scrollDefer;
|
||||
const d = this._scrollDefer;
|
||||
if (d) {
|
||||
this._scrollDefer = null;
|
||||
d.resolve();
|
||||
@ -118,29 +118,29 @@ var Tester = React.createClass({
|
||||
<li key={key} data-scroll-tokens={key}>
|
||||
<div style={{height: '98px', margin: '50px', border: '1px solid black',
|
||||
backgroundColor: '#fff8dc' }}>
|
||||
{key}
|
||||
{ key }
|
||||
</div>
|
||||
</li>
|
||||
);
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var tiles = this.state.tileKeys.map(this._mkTile);
|
||||
const tiles = this.state.tileKeys.map(this._mkTile);
|
||||
console.log("rendering with " + tiles.length + " tiles");
|
||||
return (
|
||||
<ScrollPanel ref="sp"
|
||||
onScroll={ this._onScroll }
|
||||
onFillRequest={ this._onFillRequest }>
|
||||
{tiles}
|
||||
onScroll={this._onScroll}
|
||||
onFillRequest={this._onFillRequest}>
|
||||
{ tiles }
|
||||
</ScrollPanel>
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
describe('ScrollPanel', function() {
|
||||
var parentDiv;
|
||||
var tester;
|
||||
var scrollingDiv;
|
||||
let parentDiv;
|
||||
let tester;
|
||||
let scrollingDiv;
|
||||
|
||||
beforeEach(function(done) {
|
||||
test_utils.beforeEach(this);
|
||||
@ -153,7 +153,7 @@ describe('ScrollPanel', function() {
|
||||
parentDiv.style.overflow = 'hidden';
|
||||
document.body.appendChild(parentDiv);
|
||||
|
||||
tester = ReactDOM.render(<Tester/>, parentDiv);
|
||||
tester = ReactDOM.render(<Tester />, parentDiv);
|
||||
expect(tester.fillCounts.b).toEqual(1);
|
||||
expect(tester.fillCounts.f).toEqual(1);
|
||||
|
||||
@ -226,10 +226,10 @@ describe('ScrollPanel', function() {
|
||||
});
|
||||
|
||||
it('should not get stuck in #528 workaround', function(done) {
|
||||
var events = [];
|
||||
let events = [];
|
||||
Promise.resolve().then(() => {
|
||||
// initialise with a bunch of events
|
||||
for (var i = 0; i < 40; i++) {
|
||||
for (let i = 0; i < 40; i++) {
|
||||
events.push(i);
|
||||
}
|
||||
tester.setTileKeys(events);
|
||||
@ -259,7 +259,7 @@ describe('ScrollPanel', function() {
|
||||
}).then(() => {
|
||||
// Now, simulate hitting "scroll to bottom".
|
||||
events = [];
|
||||
for (var i = 100; i < 120; i++) {
|
||||
for (let i = 100; i < 120; i++) {
|
||||
events.push(i);
|
||||
}
|
||||
tester.setTileKeys(events);
|
||||
|
@ -14,24 +14,24 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
var React = require('react');
|
||||
var ReactDOM = require('react-dom');
|
||||
var ReactTestUtils = require('react-addons-test-utils');
|
||||
var expect = require('expect');
|
||||
const React = require('react');
|
||||
const ReactDOM = require('react-dom');
|
||||
const ReactTestUtils = require('react-addons-test-utils');
|
||||
const expect = require('expect');
|
||||
import Promise from 'bluebird';
|
||||
var sinon = require('sinon');
|
||||
const sinon = require('sinon');
|
||||
|
||||
var jssdk = require('matrix-js-sdk');
|
||||
var EventTimeline = jssdk.EventTimeline;
|
||||
const jssdk = require('matrix-js-sdk');
|
||||
const EventTimeline = jssdk.EventTimeline;
|
||||
|
||||
var sdk = require('matrix-react-sdk');
|
||||
var TimelinePanel = sdk.getComponent('structures.TimelinePanel');
|
||||
var peg = require('../../../src/MatrixClientPeg');
|
||||
const sdk = require('matrix-react-sdk');
|
||||
const TimelinePanel = sdk.getComponent('structures.TimelinePanel');
|
||||
const peg = require('../../../src/MatrixClientPeg');
|
||||
|
||||
var test_utils = require('test-utils');
|
||||
const test_utils = require('test-utils');
|
||||
|
||||
var ROOM_ID = '!room:localhost';
|
||||
var USER_ID = '@me:localhost';
|
||||
const ROOM_ID = '!room:localhost';
|
||||
const USER_ID = '@me:localhost';
|
||||
|
||||
// wrap TimelinePanel with a component which provides the MatrixClient in the context.
|
||||
const WrappedTimelinePanel = React.createClass({
|
||||
@ -52,12 +52,12 @@ const WrappedTimelinePanel = React.createClass({
|
||||
|
||||
|
||||
describe('TimelinePanel', function() {
|
||||
var sandbox;
|
||||
var timelineSet;
|
||||
var room;
|
||||
var client;
|
||||
var timeline;
|
||||
var parentDiv;
|
||||
let sandbox;
|
||||
let timelineSet;
|
||||
let room;
|
||||
let client;
|
||||
let timeline;
|
||||
let parentDiv;
|
||||
|
||||
// make a dummy message. eventNum is put in the message text to help
|
||||
// identification during debugging, and also in the timestamp so that we
|
||||
@ -68,14 +68,14 @@ describe('TimelinePanel', function() {
|
||||
event: true, room: ROOM_ID, user: USER_ID,
|
||||
ts: Date.now() + eventNum,
|
||||
msg: "Event " + eventNum,
|
||||
... opts,
|
||||
...opts,
|
||||
});
|
||||
}
|
||||
|
||||
function scryEventTiles(panel) {
|
||||
return ReactTestUtils.scryRenderedComponentsWithType(
|
||||
panel, sdk.getComponent('rooms.EventTile'));
|
||||
};
|
||||
}
|
||||
|
||||
beforeEach(function() {
|
||||
test_utils.beforeEach(this);
|
||||
@ -121,8 +121,8 @@ describe('TimelinePanel', function() {
|
||||
// this is https://github.com/vector-im/vector-web/issues/1367
|
||||
|
||||
// enough events to allow us to scroll back
|
||||
var N_EVENTS = 30;
|
||||
for (var i = 0; i < N_EVENTS; i++) {
|
||||
const N_EVENTS = 30;
|
||||
for (let i = 0; i < N_EVENTS; i++) {
|
||||
timeline.addEvent(mkMessage(i));
|
||||
}
|
||||
|
||||
@ -133,26 +133,23 @@ describe('TimelinePanel', function() {
|
||||
scrollDefer.resolve();
|
||||
}
|
||||
};
|
||||
var rendered = ReactDOM.render(
|
||||
const rendered = ReactDOM.render(
|
||||
<WrappedTimelinePanel timelineSet={timelineSet} onScroll={onScroll} />,
|
||||
parentDiv,
|
||||
);
|
||||
var panel = rendered.refs.panel;
|
||||
var scrollingDiv = ReactTestUtils.findRenderedDOMComponentWithClass(
|
||||
const panel = rendered.refs.panel;
|
||||
const scrollingDiv = ReactTestUtils.findRenderedDOMComponentWithClass(
|
||||
panel, "gm-scroll-view");
|
||||
|
||||
// helper function which will return a promise which resolves when the
|
||||
// panel isn't paginating
|
||||
var awaitPaginationCompletion = function() {
|
||||
if(!panel.state.forwardPaginating)
|
||||
return Promise.resolve();
|
||||
else
|
||||
return Promise.delay(0).then(awaitPaginationCompletion);
|
||||
if(!panel.state.forwardPaginating) {return Promise.resolve();} else {return Promise.delay(0).then(awaitPaginationCompletion);}
|
||||
};
|
||||
|
||||
// helper function which will return a promise which resolves when
|
||||
// the TimelinePanel fires a scroll event
|
||||
var awaitScroll = function() {
|
||||
const awaitScroll = function() {
|
||||
scrollDefer = Promise.defer();
|
||||
return scrollDefer.promise;
|
||||
};
|
||||
@ -181,7 +178,7 @@ describe('TimelinePanel', function() {
|
||||
console.log("adding event");
|
||||
|
||||
// a new event!
|
||||
var ev = mkMessage(N_EVENTS+1);
|
||||
const ev = mkMessage(N_EVENTS+1);
|
||||
timeline.addEvent(ev);
|
||||
panel.onRoomTimeline(ev, room, false, false, {
|
||||
liveEvent: true,
|
||||
@ -204,8 +201,8 @@ describe('TimelinePanel', function() {
|
||||
it('should not paginate forever if there are no events', function(done) {
|
||||
// start with a handful of events in the timeline, as would happen when
|
||||
// joining a room
|
||||
var d = Date.now();
|
||||
for (var i = 0; i < 3; i++) {
|
||||
const d = Date.now();
|
||||
for (let i = 0; i < 3; i++) {
|
||||
timeline.addEvent(mkMessage(i));
|
||||
}
|
||||
timeline.setPaginationToken('tok', EventTimeline.BACKWARDS);
|
||||
@ -217,13 +214,13 @@ describe('TimelinePanel', function() {
|
||||
return Promise.resolve(true);
|
||||
});
|
||||
|
||||
var rendered = ReactDOM.render(
|
||||
<WrappedTimelinePanel timelineSet={timelineSet}/>,
|
||||
parentDiv
|
||||
const rendered = ReactDOM.render(
|
||||
<WrappedTimelinePanel timelineSet={timelineSet} />,
|
||||
parentDiv,
|
||||
);
|
||||
var panel = rendered.refs.panel;
|
||||
const panel = rendered.refs.panel;
|
||||
|
||||
var messagePanel = ReactTestUtils.findRenderedComponentWithType(
|
||||
const messagePanel = ReactTestUtils.findRenderedComponentWithType(
|
||||
panel, sdk.getComponent('structures.MessagePanel'));
|
||||
|
||||
expect(messagePanel.props.backPaginating).toBe(true);
|
||||
@ -249,7 +246,7 @@ describe('TimelinePanel', function() {
|
||||
});
|
||||
|
||||
it("should let you scroll down to the bottom after you've scrolled up", function(done) {
|
||||
var N_EVENTS = 120; // the number of events to simulate being added to the timeline
|
||||
const N_EVENTS = 120; // the number of events to simulate being added to the timeline
|
||||
|
||||
// sadly, loading all those events takes a while
|
||||
this.timeout(N_EVENTS * 50);
|
||||
@ -259,26 +256,26 @@ describe('TimelinePanel', function() {
|
||||
client.getRoom = function(id) { return null; };
|
||||
|
||||
// fill the timeline with lots of events
|
||||
for (var i = 0; i < N_EVENTS; i++) {
|
||||
for (let i = 0; i < N_EVENTS; i++) {
|
||||
timeline.addEvent(mkMessage(i));
|
||||
}
|
||||
console.log("added events to timeline");
|
||||
|
||||
var scrollDefer;
|
||||
var rendered = ReactDOM.render(
|
||||
<WrappedTimelinePanel timelineSet={timelineSet} onScroll={() => {scrollDefer.resolve()}}/>,
|
||||
parentDiv
|
||||
let scrollDefer;
|
||||
const rendered = ReactDOM.render(
|
||||
<WrappedTimelinePanel timelineSet={timelineSet} onScroll={() => {scrollDefer.resolve();}} />,
|
||||
parentDiv,
|
||||
);
|
||||
console.log("TimelinePanel rendered");
|
||||
var panel = rendered.refs.panel;
|
||||
var messagePanel = ReactTestUtils.findRenderedComponentWithType(
|
||||
const panel = rendered.refs.panel;
|
||||
const messagePanel = ReactTestUtils.findRenderedComponentWithType(
|
||||
panel, sdk.getComponent('structures.MessagePanel'));
|
||||
var scrollingDiv = ReactTestUtils.findRenderedDOMComponentWithClass(
|
||||
const scrollingDiv = ReactTestUtils.findRenderedDOMComponentWithClass(
|
||||
panel, "gm-scroll-view");
|
||||
|
||||
// helper function which will return a promise which resolves when
|
||||
// the TimelinePanel fires a scroll event
|
||||
var awaitScroll = function() {
|
||||
const awaitScroll = function() {
|
||||
scrollDefer = Promise.defer();
|
||||
|
||||
return scrollDefer.promise.then(() => {
|
||||
@ -299,8 +296,8 @@ describe('TimelinePanel', function() {
|
||||
console.log("back paginating...");
|
||||
setScrollTop(0);
|
||||
return awaitScroll().then(() => {
|
||||
let eventTiles = scryEventTiles(panel);
|
||||
let firstEvent = eventTiles[0].props.mxEvent;
|
||||
const eventTiles = scryEventTiles(panel);
|
||||
const firstEvent = eventTiles[0].props.mxEvent;
|
||||
|
||||
console.log("TimelinePanel contains " + eventTiles.length +
|
||||
" events; first is " +
|
||||
@ -319,12 +316,11 @@ describe('TimelinePanel', function() {
|
||||
setScrollTop(scrollingDiv.scrollHeight - scrollingDiv.clientHeight);
|
||||
console.log("scrolling down... " + scrollingDiv.scrollTop);
|
||||
return awaitScroll().delay(0).then(() => {
|
||||
const eventTiles = scryEventTiles(panel);
|
||||
const events = timeline.getEvents();
|
||||
|
||||
let eventTiles = scryEventTiles(panel);
|
||||
let events = timeline.getEvents();
|
||||
|
||||
let lastEventInPanel = eventTiles[eventTiles.length - 1].props.mxEvent;
|
||||
let lastEventInTimeline = events[events.length - 1];
|
||||
const lastEventInPanel = eventTiles[eventTiles.length - 1].props.mxEvent;
|
||||
const lastEventInTimeline = events[events.length - 1];
|
||||
|
||||
// Scroll until the last event in the panel = the last event in the timeline
|
||||
if(lastEventInPanel.getId() !== lastEventInTimeline.getId()) {
|
||||
@ -348,7 +344,7 @@ describe('TimelinePanel', function() {
|
||||
expect(messagePanel.props.backPaginating).toBe(false);
|
||||
|
||||
expect(messagePanel.props.suppressFirstDateSeparator).toBe(false);
|
||||
var events = scryEventTiles(panel);
|
||||
const events = scryEventTiles(panel);
|
||||
expect(events[0].props.mxEvent).toBe(timeline.getEvents()[0]);
|
||||
|
||||
// At this point, we make no assumption that unpagination has happened. This doesn't
|
||||
@ -361,11 +357,11 @@ describe('TimelinePanel', function() {
|
||||
expect(messagePanel.props.backPaginating).toBe(false);
|
||||
expect(messagePanel.props.forwardPaginating).toBe(false);
|
||||
|
||||
var events = scryEventTiles(panel);
|
||||
const events = scryEventTiles(panel);
|
||||
|
||||
// Expect to be able to see the most recent event
|
||||
var lastEventInPanel = events[events.length - 1].props.mxEvent;
|
||||
var lastEventInTimeline = timeline.getEvents()[timeline.getEvents().length - 1];
|
||||
const lastEventInPanel = events[events.length - 1].props.mxEvent;
|
||||
const lastEventInTimeline = timeline.getEvents()[timeline.getEvents().length - 1];
|
||||
expect(lastEventInPanel.getContent()).toBe(lastEventInTimeline.getContent());
|
||||
|
||||
console.log("done");
|
||||
|
@ -2,7 +2,7 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var React = require('react');
|
||||
const React = require('react');
|
||||
|
||||
module.exports = function(opts) {
|
||||
opts = opts || {};
|
||||
@ -12,8 +12,8 @@ module.exports = function(opts) {
|
||||
|
||||
if (!opts.render) {
|
||||
opts.render = function() {
|
||||
return <div>{this.displayName}</div>;
|
||||
}
|
||||
return <div>{ this.displayName }</div>;
|
||||
};
|
||||
}
|
||||
|
||||
return React.createClass(opts);
|
||||
|
@ -28,12 +28,12 @@ import MatrixClientPeg from '../../../../src/MatrixClientPeg';
|
||||
import * as test_utils from '../../../test-utils';
|
||||
|
||||
const InteractiveAuthDialog = sdk.getComponent(
|
||||
'views.dialogs.InteractiveAuthDialog'
|
||||
'views.dialogs.InteractiveAuthDialog',
|
||||
);
|
||||
|
||||
describe('InteractiveAuthDialog', function () {
|
||||
var parentDiv;
|
||||
var sandbox;
|
||||
describe('InteractiveAuthDialog', function() {
|
||||
let parentDiv;
|
||||
let sandbox;
|
||||
|
||||
beforeEach(function() {
|
||||
test_utils.beforeEach(this);
|
||||
@ -50,10 +50,10 @@ describe('InteractiveAuthDialog', function () {
|
||||
|
||||
it('Should successfully complete a password flow', function() {
|
||||
const onFinished = sinon.spy();
|
||||
const doRequest = sinon.stub().returns(Promise.resolve({a:1}));
|
||||
const doRequest = sinon.stub().returns(Promise.resolve({a: 1}));
|
||||
|
||||
// tell the stub matrixclient to return a real userid
|
||||
var client = MatrixClientPeg.get();
|
||||
const client = MatrixClientPeg.get();
|
||||
client.credentials = {userId: "@user:id"};
|
||||
|
||||
const dlg = ReactDOM.render(
|
||||
@ -62,8 +62,8 @@ describe('InteractiveAuthDialog', function () {
|
||||
authData={{
|
||||
session: "sess",
|
||||
flows: [
|
||||
{"stages":["m.login.password"]}
|
||||
]
|
||||
{"stages": ["m.login.password"]},
|
||||
],
|
||||
}}
|
||||
makeRequest={doRequest}
|
||||
onFinished={onFinished}
|
||||
@ -72,7 +72,7 @@ describe('InteractiveAuthDialog', function () {
|
||||
// wait for a password box and a submit button
|
||||
return MatrixReactTestUtils.waitForRenderedDOMComponentWithTag(dlg, "form", 2).then((formNode) => {
|
||||
const inputNodes = ReactTestUtils.scryRenderedDOMComponentsWithTag(
|
||||
dlg, "input"
|
||||
dlg, "input",
|
||||
);
|
||||
let passwordNode;
|
||||
let submitNode;
|
||||
@ -113,7 +113,7 @@ describe('InteractiveAuthDialog', function () {
|
||||
return Promise.delay(1);
|
||||
}).then(() => {
|
||||
expect(onFinished.callCount).toEqual(1);
|
||||
expect(onFinished.calledWithExactly(true, {a:1})).toBe(true);
|
||||
expect(onFinished.calledWithExactly(true, {a: 1})).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -155,10 +155,10 @@ describe('MemberEventListSummary', function() {
|
||||
};
|
||||
|
||||
const instance = ReactTestUtils.renderIntoDocument(
|
||||
<MemberEventListSummary {...props} />
|
||||
<MemberEventListSummary {...props} />,
|
||||
);
|
||||
const summary = ReactTestUtils.findRenderedDOMComponentWithClass(
|
||||
instance, "mx_MemberEventListSummary_summary"
|
||||
instance, "mx_MemberEventListSummary_summary",
|
||||
);
|
||||
const summaryText = summary.innerText;
|
||||
|
||||
@ -191,10 +191,10 @@ describe('MemberEventListSummary', function() {
|
||||
};
|
||||
|
||||
const instance = ReactTestUtils.renderIntoDocument(
|
||||
<MemberEventListSummary {...props} />
|
||||
<MemberEventListSummary {...props} />,
|
||||
);
|
||||
const summary = ReactTestUtils.findRenderedDOMComponentWithClass(
|
||||
instance, "mx_MemberEventListSummary_summary"
|
||||
instance, "mx_MemberEventListSummary_summary",
|
||||
);
|
||||
const summaryText = summary.innerText;
|
||||
|
||||
@ -239,15 +239,15 @@ describe('MemberEventListSummary', function() {
|
||||
};
|
||||
|
||||
const instance = ReactTestUtils.renderIntoDocument(
|
||||
<MemberEventListSummary {...props} />
|
||||
<MemberEventListSummary {...props} />,
|
||||
);
|
||||
const summary = ReactTestUtils.findRenderedDOMComponentWithClass(
|
||||
instance, "mx_MemberEventListSummary_summary"
|
||||
instance, "mx_MemberEventListSummary_summary",
|
||||
);
|
||||
const summaryText = summary.innerText;
|
||||
|
||||
expect(summaryText).toBe(
|
||||
"user_1 was unbanned, joined and left 7 times and was invited"
|
||||
"user_1 was unbanned, joined and left 7 times and was invited",
|
||||
);
|
||||
});
|
||||
|
||||
@ -292,16 +292,16 @@ describe('MemberEventListSummary', function() {
|
||||
};
|
||||
|
||||
const instance = ReactTestUtils.renderIntoDocument(
|
||||
<MemberEventListSummary {...props} />
|
||||
<MemberEventListSummary {...props} />,
|
||||
);
|
||||
const summary = ReactTestUtils.findRenderedDOMComponentWithClass(
|
||||
instance, "mx_MemberEventListSummary_summary"
|
||||
instance, "mx_MemberEventListSummary_summary",
|
||||
);
|
||||
const summaryText = summary.innerText;
|
||||
|
||||
expect(summaryText).toBe(
|
||||
"user_1 was unbanned, joined and left 2 times, was banned, " +
|
||||
"joined and left 3 times and was invited"
|
||||
"joined and left 3 times and was invited",
|
||||
);
|
||||
});
|
||||
|
||||
@ -351,15 +351,15 @@ describe('MemberEventListSummary', function() {
|
||||
};
|
||||
|
||||
const instance = ReactTestUtils.renderIntoDocument(
|
||||
<MemberEventListSummary {...props} />
|
||||
<MemberEventListSummary {...props} />,
|
||||
);
|
||||
const summary = ReactTestUtils.findRenderedDOMComponentWithClass(
|
||||
instance, "mx_MemberEventListSummary_summary"
|
||||
instance, "mx_MemberEventListSummary_summary",
|
||||
);
|
||||
const summaryText = summary.innerText;
|
||||
|
||||
expect(summaryText).toBe(
|
||||
"user_1 and one other were unbanned, joined and left 2 times and were banned"
|
||||
"user_1 and one other were unbanned, joined and left 2 times and were banned",
|
||||
);
|
||||
});
|
||||
|
||||
@ -389,15 +389,15 @@ describe('MemberEventListSummary', function() {
|
||||
};
|
||||
|
||||
const instance = ReactTestUtils.renderIntoDocument(
|
||||
<MemberEventListSummary {...props} />
|
||||
<MemberEventListSummary {...props} />,
|
||||
);
|
||||
const summary = ReactTestUtils.findRenderedDOMComponentWithClass(
|
||||
instance, "mx_MemberEventListSummary_summary"
|
||||
instance, "mx_MemberEventListSummary_summary",
|
||||
);
|
||||
const summaryText = summary.innerText;
|
||||
|
||||
expect(summaryText).toBe(
|
||||
"user_0 and 19 others were unbanned, joined and left 2 times and were banned"
|
||||
"user_0 and 19 others were unbanned, joined and left 2 times and were banned",
|
||||
);
|
||||
});
|
||||
|
||||
@ -440,16 +440,16 @@ describe('MemberEventListSummary', function() {
|
||||
};
|
||||
|
||||
const instance = ReactTestUtils.renderIntoDocument(
|
||||
<MemberEventListSummary {...props} />
|
||||
<MemberEventListSummary {...props} />,
|
||||
);
|
||||
const summary = ReactTestUtils.findRenderedDOMComponentWithClass(
|
||||
instance, "mx_MemberEventListSummary_summary"
|
||||
instance, "mx_MemberEventListSummary_summary",
|
||||
);
|
||||
const summaryText = summary.innerText;
|
||||
|
||||
expect(summaryText).toBe(
|
||||
"user_2 was unbanned and joined and left 2 times, user_1 was unbanned, " +
|
||||
"joined and left 2 times and was banned"
|
||||
"joined and left 2 times and was banned",
|
||||
);
|
||||
});
|
||||
|
||||
@ -507,16 +507,16 @@ describe('MemberEventListSummary', function() {
|
||||
};
|
||||
|
||||
const instance = ReactTestUtils.renderIntoDocument(
|
||||
<MemberEventListSummary {...props} />
|
||||
<MemberEventListSummary {...props} />,
|
||||
);
|
||||
const summary = ReactTestUtils.findRenderedDOMComponentWithClass(
|
||||
instance, "mx_MemberEventListSummary_summary"
|
||||
instance, "mx_MemberEventListSummary_summary",
|
||||
);
|
||||
const summaryText = summary.innerText;
|
||||
|
||||
expect(summaryText).toBe(
|
||||
"user_1 was invited, was banned, joined, rejected their invitation, left, " +
|
||||
"had their invitation withdrawn, was unbanned, was kicked and left"
|
||||
"had their invitation withdrawn, was unbanned, was kicked and left",
|
||||
);
|
||||
});
|
||||
|
||||
@ -554,16 +554,16 @@ describe('MemberEventListSummary', function() {
|
||||
};
|
||||
|
||||
const instance = ReactTestUtils.renderIntoDocument(
|
||||
<MemberEventListSummary {...props} />
|
||||
<MemberEventListSummary {...props} />,
|
||||
);
|
||||
const summary = ReactTestUtils.findRenderedDOMComponentWithClass(
|
||||
instance, "mx_MemberEventListSummary_summary"
|
||||
instance, "mx_MemberEventListSummary_summary",
|
||||
);
|
||||
const summaryText = summary.innerText;
|
||||
|
||||
expect(summaryText).toBe(
|
||||
"user_1 and one other rejected their invitations and " +
|
||||
"had their invitations withdrawn"
|
||||
"had their invitations withdrawn",
|
||||
);
|
||||
});
|
||||
|
||||
@ -590,15 +590,15 @@ describe('MemberEventListSummary', function() {
|
||||
};
|
||||
|
||||
const instance = ReactTestUtils.renderIntoDocument(
|
||||
<MemberEventListSummary {...props} />
|
||||
<MemberEventListSummary {...props} />,
|
||||
);
|
||||
const summary = ReactTestUtils.findRenderedDOMComponentWithClass(
|
||||
instance, "mx_MemberEventListSummary_summary"
|
||||
instance, "mx_MemberEventListSummary_summary",
|
||||
);
|
||||
const summaryText = summary.innerText;
|
||||
|
||||
expect(summaryText).toBe(
|
||||
"user_1 rejected their invitation 2 times"
|
||||
"user_1 rejected their invitation 2 times",
|
||||
);
|
||||
});
|
||||
|
||||
@ -618,15 +618,15 @@ describe('MemberEventListSummary', function() {
|
||||
};
|
||||
|
||||
const instance = ReactTestUtils.renderIntoDocument(
|
||||
<MemberEventListSummary {...props} />
|
||||
<MemberEventListSummary {...props} />,
|
||||
);
|
||||
const summary = ReactTestUtils.findRenderedDOMComponentWithClass(
|
||||
instance, "mx_MemberEventListSummary_summary"
|
||||
instance, "mx_MemberEventListSummary_summary",
|
||||
);
|
||||
const summaryText = summary.innerText;
|
||||
|
||||
expect(summaryText).toBe(
|
||||
"user_1 and user_2 joined 2 times"
|
||||
"user_1 and user_2 joined 2 times",
|
||||
);
|
||||
});
|
||||
|
||||
@ -645,15 +645,15 @@ describe('MemberEventListSummary', function() {
|
||||
};
|
||||
|
||||
const instance = ReactTestUtils.renderIntoDocument(
|
||||
<MemberEventListSummary {...props} />
|
||||
<MemberEventListSummary {...props} />,
|
||||
);
|
||||
const summary = ReactTestUtils.findRenderedDOMComponentWithClass(
|
||||
instance, "mx_MemberEventListSummary_summary"
|
||||
instance, "mx_MemberEventListSummary_summary",
|
||||
);
|
||||
const summaryText = summary.innerText;
|
||||
|
||||
expect(summaryText).toBe(
|
||||
"user_1, user_2 and one other joined"
|
||||
"user_1, user_2 and one other joined",
|
||||
);
|
||||
});
|
||||
|
||||
@ -670,15 +670,15 @@ describe('MemberEventListSummary', function() {
|
||||
};
|
||||
|
||||
const instance = ReactTestUtils.renderIntoDocument(
|
||||
<MemberEventListSummary {...props} />
|
||||
<MemberEventListSummary {...props} />,
|
||||
);
|
||||
const summary = ReactTestUtils.findRenderedDOMComponentWithClass(
|
||||
instance, "mx_MemberEventListSummary_summary"
|
||||
instance, "mx_MemberEventListSummary_summary",
|
||||
);
|
||||
const summaryText = summary.innerText;
|
||||
|
||||
expect(summaryText).toBe(
|
||||
"user_0, user_1 and 18 others joined"
|
||||
"user_0, user_1 and 18 others joined",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -57,7 +57,7 @@ describe('MessageComposerInput', () => {
|
||||
}
|
||||
sandbox.restore();
|
||||
done();
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
// XXX this fails
|
||||
|
Reference in New Issue
Block a user