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:
+1
-1
@@ -3,5 +3,5 @@
|
||||
// Our master test file: uses the webpack require API to find our test files
|
||||
// and run them
|
||||
|
||||
var context = require.context('.', true, /-test\.jsx?$/);
|
||||
const context = require.context('.', true, /-test\.jsx?$/);
|
||||
context.keys().forEach(context);
|
||||
|
||||
@@ -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
|
||||
|
||||
+32
-32
@@ -37,28 +37,28 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* mock_clock.uninstall();
|
||||
*
|
||||
*
|
||||
*
|
||||
* The reason for C&Ping jasmine's clock here is that jasmine itself is
|
||||
* difficult to webpack, and we don't really want all of it. Sinon also has a
|
||||
* mock-clock implementation, but again, it is difficult to webpack.
|
||||
*/
|
||||
|
||||
var j$ = {};
|
||||
const j$ = {};
|
||||
|
||||
j$.Clock = function () {
|
||||
j$.Clock = function() {
|
||||
function Clock(global, delayedFunctionSchedulerFactory, mockDate) {
|
||||
var self = this,
|
||||
let self = this,
|
||||
realTimingFunctions = {
|
||||
setTimeout: global.setTimeout,
|
||||
clearTimeout: global.clearTimeout,
|
||||
setInterval: global.setInterval,
|
||||
clearInterval: global.clearInterval
|
||||
clearInterval: global.clearInterval,
|
||||
},
|
||||
fakeTimingFunctions = {
|
||||
setTimeout: setTimeout,
|
||||
clearTimeout: clearTimeout,
|
||||
setInterval: setInterval,
|
||||
clearInterval: clearInterval
|
||||
clearInterval: clearInterval,
|
||||
},
|
||||
installed = false,
|
||||
delayedFunctionScheduler,
|
||||
@@ -151,7 +151,7 @@ j$.Clock = function () {
|
||||
}
|
||||
|
||||
function replace(dest, source) {
|
||||
for (var prop in source) {
|
||||
for (const prop in source) {
|
||||
dest[prop] = source[prop];
|
||||
}
|
||||
}
|
||||
@@ -183,22 +183,22 @@ j$.Clock = function () {
|
||||
|
||||
j$.DelayedFunctionScheduler = function() {
|
||||
function DelayedFunctionScheduler() {
|
||||
var self = this;
|
||||
var scheduledLookup = [];
|
||||
var scheduledFunctions = {};
|
||||
var currentTime = 0;
|
||||
var delayedFnCount = 0;
|
||||
const self = this;
|
||||
const scheduledLookup = [];
|
||||
const scheduledFunctions = {};
|
||||
let currentTime = 0;
|
||||
let delayedFnCount = 0;
|
||||
|
||||
self.tick = function(millis) {
|
||||
millis = millis || 0;
|
||||
var endTime = currentTime + millis;
|
||||
const endTime = currentTime + millis;
|
||||
|
||||
runScheduledFunctions(endTime);
|
||||
currentTime = endTime;
|
||||
};
|
||||
|
||||
self.scheduleFunction = function(funcToCall, millis, params, recurring, timeoutKey, runAtMillis) {
|
||||
var f;
|
||||
let f;
|
||||
if (typeof(funcToCall) === 'string') {
|
||||
/* jshint evil: true */
|
||||
f = function() { return eval(funcToCall); };
|
||||
@@ -211,13 +211,13 @@ j$.DelayedFunctionScheduler = function() {
|
||||
timeoutKey = timeoutKey || ++delayedFnCount;
|
||||
runAtMillis = runAtMillis || (currentTime + millis);
|
||||
|
||||
var funcToSchedule = {
|
||||
const funcToSchedule = {
|
||||
runAtMillis: runAtMillis,
|
||||
funcToCall: f,
|
||||
recurring: recurring,
|
||||
params: params,
|
||||
timeoutKey: timeoutKey,
|
||||
millis: millis
|
||||
millis: millis,
|
||||
};
|
||||
|
||||
if (runAtMillis in scheduledFunctions) {
|
||||
@@ -225,7 +225,7 @@ j$.DelayedFunctionScheduler = function() {
|
||||
} else {
|
||||
scheduledFunctions[runAtMillis] = [funcToSchedule];
|
||||
scheduledLookup.push(runAtMillis);
|
||||
scheduledLookup.sort(function (a, b) {
|
||||
scheduledLookup.sort(function(a, b) {
|
||||
return a - b;
|
||||
});
|
||||
}
|
||||
@@ -234,9 +234,9 @@ j$.DelayedFunctionScheduler = function() {
|
||||
};
|
||||
|
||||
self.removeFunctionWithId = function(timeoutKey) {
|
||||
for (var runAtMillis in scheduledFunctions) {
|
||||
var funcs = scheduledFunctions[runAtMillis];
|
||||
var i = indexOfFirstToPass(funcs, function (func) {
|
||||
for (const runAtMillis in scheduledFunctions) {
|
||||
const funcs = scheduledFunctions[runAtMillis];
|
||||
const i = indexOfFirstToPass(funcs, function(func) {
|
||||
return func.timeoutKey === timeoutKey;
|
||||
});
|
||||
|
||||
@@ -258,9 +258,9 @@ j$.DelayedFunctionScheduler = function() {
|
||||
return self;
|
||||
|
||||
function indexOfFirstToPass(array, testFn) {
|
||||
var index = -1;
|
||||
let index = -1;
|
||||
|
||||
for (var i = 0; i < array.length; ++i) {
|
||||
for (let i = 0; i < array.length; ++i) {
|
||||
if (testFn(array[i])) {
|
||||
index = i;
|
||||
break;
|
||||
@@ -271,8 +271,8 @@ j$.DelayedFunctionScheduler = function() {
|
||||
}
|
||||
|
||||
function deleteFromLookup(key) {
|
||||
var value = Number(key);
|
||||
var i = indexOfFirstToPass(scheduledLookup, function (millis) {
|
||||
const value = Number(key);
|
||||
const i = indexOfFirstToPass(scheduledLookup, function(millis) {
|
||||
return millis === value;
|
||||
});
|
||||
|
||||
@@ -291,7 +291,7 @@ j$.DelayedFunctionScheduler = function() {
|
||||
}
|
||||
|
||||
function forEachFunction(funcsToRun, callback) {
|
||||
for (var i = 0; i < funcsToRun.length; ++i) {
|
||||
for (let i = 0; i < funcsToRun.length; ++i) {
|
||||
callback(funcsToRun[i]);
|
||||
}
|
||||
}
|
||||
@@ -304,7 +304,7 @@ j$.DelayedFunctionScheduler = function() {
|
||||
do {
|
||||
currentTime = scheduledLookup.shift();
|
||||
|
||||
var funcsToRun = scheduledFunctions[currentTime];
|
||||
const funcsToRun = scheduledFunctions[currentTime];
|
||||
delete scheduledFunctions[currentTime];
|
||||
|
||||
forEachFunction(funcsToRun, function(funcToRun) {
|
||||
@@ -319,7 +319,7 @@ j$.DelayedFunctionScheduler = function() {
|
||||
} while (scheduledLookup.length > 0 &&
|
||||
// checking first if we're out of time prevents setTimeout(0)
|
||||
// scheduled in a funcToRun from forcing an extra iteration
|
||||
currentTime !== endTime &&
|
||||
currentTime !== endTime &&
|
||||
scheduledLookup[0] <= endTime);
|
||||
}
|
||||
}
|
||||
@@ -330,8 +330,8 @@ j$.DelayedFunctionScheduler = function() {
|
||||
|
||||
j$.MockDate = function() {
|
||||
function MockDate(global) {
|
||||
var self = this;
|
||||
var currentTime = 0;
|
||||
const self = this;
|
||||
let currentTime = 0;
|
||||
|
||||
if (!global || !global.Date) {
|
||||
self.install = function() {};
|
||||
@@ -340,7 +340,7 @@ j$.MockDate = function() {
|
||||
return self;
|
||||
}
|
||||
|
||||
var GlobalDate = global.Date;
|
||||
const GlobalDate = global.Date;
|
||||
|
||||
self.install = function(mockDate) {
|
||||
if (mockDate instanceof GlobalDate) {
|
||||
@@ -411,10 +411,10 @@ j$.MockDate = function() {
|
||||
return MockDate;
|
||||
}();
|
||||
|
||||
var clock = new j$.Clock(global, function () { return new j$.DelayedFunctionScheduler(); }, new j$.MockDate(global));
|
||||
const clock = new j$.Clock(global, function() { return new j$.DelayedFunctionScheduler(); }, new j$.MockDate(global));
|
||||
|
||||
module.exports.clock = function() {
|
||||
return clock;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
+4
-4
@@ -13,12 +13,12 @@
|
||||
// default
|
||||
require('babel-polyfill');
|
||||
|
||||
var sdk = require("../src/index");
|
||||
const sdk = require("../src/index");
|
||||
|
||||
var skin = require('../src/component-index.js');
|
||||
var stubComponent = require('./components/stub-component.js');
|
||||
const skin = require('../src/component-index.js');
|
||||
const stubComponent = require('./components/stub-component.js');
|
||||
|
||||
var components = skin.components;
|
||||
const components = skin.components;
|
||||
components['structures.LeftPanel'] = stubComponent();
|
||||
components['structures.RightPanel'] = stubComponent();
|
||||
components['structures.RoomDirectory'] = stubComponent();
|
||||
|
||||
+18
-19
@@ -14,7 +14,7 @@ const MatrixEvent = jssdk.MatrixEvent;
|
||||
* @param {Mocha.Context} context The test context
|
||||
*/
|
||||
export function beforeEach(context) {
|
||||
var desc = context.currentTest.fullTitle();
|
||||
const desc = context.currentTest.fullTitle();
|
||||
|
||||
console.log();
|
||||
|
||||
@@ -26,7 +26,7 @@ export function beforeEach(context) {
|
||||
|
||||
console.log(desc);
|
||||
console.log(new Array(1 + desc.length).join("="));
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -40,16 +40,16 @@ export function beforeEach(context) {
|
||||
* @returns {sinon.Sandbox}; remember to call sandbox.restore afterwards.
|
||||
*/
|
||||
export function stubClient() {
|
||||
var sandbox = sinon.sandbox.create();
|
||||
const sandbox = sinon.sandbox.create();
|
||||
|
||||
var client = createTestClient();
|
||||
const client = createTestClient();
|
||||
|
||||
// stub out the methods in MatrixClientPeg
|
||||
//
|
||||
// 'sandbox.restore()' doesn't work correctly on inherited methods,
|
||||
// so we do this for each method
|
||||
var methods = ['get', 'unset', 'replaceUsingCreds'];
|
||||
for (var i = 0; i < methods.length; i++) {
|
||||
const methods = ['get', 'unset', 'replaceUsingCreds'];
|
||||
for (let i = 0; i < methods.length; i++) {
|
||||
sandbox.stub(peg, methods[i]);
|
||||
}
|
||||
// MatrixClientPeg.get() is called a /lot/, so implement it with our own
|
||||
@@ -128,7 +128,7 @@ export function mkEvent(opts) {
|
||||
if (!opts.type || !opts.content) {
|
||||
throw new Error("Missing .type or .content =>" + JSON.stringify(opts));
|
||||
}
|
||||
var event = {
|
||||
const event = {
|
||||
type: opts.type,
|
||||
room_id: opts.room,
|
||||
sender: opts.user,
|
||||
@@ -139,14 +139,13 @@ export function mkEvent(opts) {
|
||||
};
|
||||
if (opts.skey) {
|
||||
event.state_key = opts.skey;
|
||||
}
|
||||
else if (["m.room.name", "m.room.topic", "m.room.create", "m.room.join_rules",
|
||||
} else if (["m.room.name", "m.room.topic", "m.room.create", "m.room.join_rules",
|
||||
"m.room.power_levels", "m.room.topic",
|
||||
"com.example.state"].indexOf(opts.type) !== -1) {
|
||||
event.state_key = "";
|
||||
}
|
||||
return opts.event ? new MatrixEvent(event) : event;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an m.presence event.
|
||||
@@ -157,7 +156,7 @@ export function mkPresence(opts) {
|
||||
if (!opts.user) {
|
||||
throw new Error("Missing user");
|
||||
}
|
||||
var event = {
|
||||
const event = {
|
||||
event_id: "$" + Math.random() + "-" + Math.random(),
|
||||
type: "m.presence",
|
||||
sender: opts.user,
|
||||
@@ -165,11 +164,11 @@ export function mkPresence(opts) {
|
||||
avatar_url: opts.url,
|
||||
displayname: opts.name,
|
||||
last_active_ago: opts.ago,
|
||||
presence: opts.presence || "offline"
|
||||
}
|
||||
presence: opts.presence || "offline",
|
||||
},
|
||||
};
|
||||
return opts.event ? new MatrixEvent(event) : event;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an m.room.member event.
|
||||
@@ -195,19 +194,19 @@ export function mkMembership(opts) {
|
||||
throw new Error("Missing .mship => " + JSON.stringify(opts));
|
||||
}
|
||||
opts.content = {
|
||||
membership: opts.mship
|
||||
membership: opts.mship,
|
||||
};
|
||||
if (opts.prevMship) {
|
||||
opts.prev_content = { membership: opts.prevMship };
|
||||
}
|
||||
if (opts.name) { opts.content.displayname = opts.name; }
|
||||
if (opts.url) { opts.content.avatar_url = opts.url; }
|
||||
let e = mkEvent(opts);
|
||||
const e = mkEvent(opts);
|
||||
if (opts.target) {
|
||||
e.target = opts.target;
|
||||
}
|
||||
return e;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an m.room.message event.
|
||||
@@ -228,13 +227,13 @@ export function mkMessage(opts) {
|
||||
}
|
||||
opts.content = {
|
||||
msgtype: "m.text",
|
||||
body: opts.msg
|
||||
body: opts.msg,
|
||||
};
|
||||
return mkEvent(opts);
|
||||
}
|
||||
|
||||
export function mkStubRoom(roomId = null) {
|
||||
var stubTimeline = { getEvents: () => [] };
|
||||
const stubTimeline = { getEvents: () => [] };
|
||||
return {
|
||||
roomId,
|
||||
getReceiptsForEvent: sinon.stub().returns([]),
|
||||
|
||||
Reference in New Issue
Block a user