Skip to content

Commit 70fe4f6

Browse files
committed
eslint --fix on test/
1 parent 6abd1de commit 70fe4f6

File tree

5 files changed

+57
-58
lines changed

5 files changed

+57
-58
lines changed

test/all-tests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
// ideally these unit tests could be run under nodejs rather than in a browser
77
// via karma, but having two separate test frameworks in the same project
88
// seems confusing
9-
var unit_tests = require.context('./unit-tests', true, /\.js$/);
9+
const unit_tests = require.context('./unit-tests', true, /\.js$/);
1010
unit_tests.keys().forEach(unit_tests);
1111

12-
var app_tests = require.context('./app-tests', true, /\.jsx?$/);
12+
const app_tests = require.context('./app-tests', true, /\.jsx?$/);
1313
app_tests.keys().forEach(app_tests);

test/app-tests/joining.js

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,36 +21,36 @@ import Platform from '../../src/vector/platform';
2121

2222
require('skin-sdk');
2323

24-
var jssdk = require('matrix-js-sdk');
25-
26-
var sdk = require('matrix-react-sdk');
27-
var peg = require('matrix-react-sdk/lib/MatrixClientPeg');
28-
var dis = require('matrix-react-sdk/lib/dispatcher');
29-
var PageTypes = require('matrix-react-sdk/lib/PageTypes');
30-
var MatrixChat = sdk.getComponent('structures.MatrixChat');
31-
var RoomDirectory = sdk.getComponent('structures.RoomDirectory');
32-
var RoomPreviewBar = sdk.getComponent('rooms.RoomPreviewBar');
33-
var RoomView = sdk.getComponent('structures.RoomView');
34-
35-
var React = require('react');
36-
var ReactDOM = require('react-dom');
37-
var ReactTestUtils = require('react-addons-test-utils');
38-
var expect = require('expect');
24+
const jssdk = require('matrix-js-sdk');
25+
26+
const sdk = require('matrix-react-sdk');
27+
const peg = require('matrix-react-sdk/lib/MatrixClientPeg');
28+
const dis = require('matrix-react-sdk/lib/dispatcher');
29+
const PageTypes = require('matrix-react-sdk/lib/PageTypes');
30+
const MatrixChat = sdk.getComponent('structures.MatrixChat');
31+
const RoomDirectory = sdk.getComponent('structures.RoomDirectory');
32+
const RoomPreviewBar = sdk.getComponent('rooms.RoomPreviewBar');
33+
const RoomView = sdk.getComponent('structures.RoomView');
34+
35+
const React = require('react');
36+
const ReactDOM = require('react-dom');
37+
const ReactTestUtils = require('react-addons-test-utils');
38+
const expect = require('expect');
3939
import Promise from 'bluebird';
4040

41-
var test_utils = require('../test-utils');
42-
var MockHttpBackend = require('matrix-mock-request');
41+
const test_utils = require('../test-utils');
42+
const MockHttpBackend = require('matrix-mock-request');
4343

44-
var HS_URL='http://localhost';
45-
var IS_URL='http://localhost';
46-
var USER_ID='@me:localhost';
47-
var ACCESS_TOKEN='access_token';
44+
const HS_URL='http://localhost';
45+
const IS_URL='http://localhost';
46+
const USER_ID='@me:localhost';
47+
const ACCESS_TOKEN='access_token';
4848

49-
describe('joining a room', function () {
50-
describe('over federation', function () {
51-
var parentDiv;
52-
var httpBackend;
53-
var matrixChat;
49+
describe('joining a room', function() {
50+
describe('over federation', function() {
51+
let parentDiv;
52+
let httpBackend;
53+
let matrixChat;
5454

5555
beforeEach(function() {
5656
test_utils.beforeEach(this);
@@ -72,8 +72,8 @@ describe('joining a room', function () {
7272
});
7373

7474
it('should not get stuck at a spinner', function() {
75-
var ROOM_ALIAS = '#alias:localhost';
76-
var ROOM_ID = '!id:localhost';
75+
const ROOM_ALIAS = '#alias:localhost';
76+
const ROOM_ID = '!id:localhost';
7777

7878
httpBackend.when('GET', '/pushrules').respond(200, {});
7979
httpBackend.when('POST', '/filter').respond(200, { filter_id: 'fid' });
@@ -90,7 +90,7 @@ describe('joining a room', function () {
9090

9191
PlatformPeg.set(new Platform());
9292

93-
var mc = (
93+
const mc = (
9494
<MatrixChat config={{}}
9595
makeRegistrationUrl={()=>{throw new Error("unimplemented");}}
9696
initialScreenAfterLogin={{
@@ -100,7 +100,7 @@ describe('joining a room', function () {
100100
);
101101
matrixChat = ReactDOM.render(mc, parentDiv);
102102

103-
var roomView;
103+
let roomView;
104104

105105
// wait for /sync to happen. This may take some time, as the client
106106
// has to initialise indexeddb.
@@ -118,11 +118,11 @@ describe('joining a room', function () {
118118
}).then(() => {
119119
console.log(`${Date.now()} App made requests for directory view; switching to a room.`);
120120

121-
var roomDir = ReactTestUtils.findRenderedComponentWithType(
121+
const roomDir = ReactTestUtils.findRenderedComponentWithType(
122122
matrixChat, RoomDirectory);
123123

124124
// enter an alias in the input, and simulate enter
125-
var input = ReactTestUtils.findRenderedDOMComponentWithTag(
125+
const input = ReactTestUtils.findRenderedDOMComponentWithTag(
126126
roomDir, 'input');
127127
input.value = ROOM_ALIAS;
128128
ReactTestUtils.Simulate.change(input);

test/app-tests/loading.js

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ import * as test_utils from '../test-utils';
4040
import MockHttpBackend from 'matrix-mock-request';
4141
import {parseQs, parseQsFromFragment} from '../../src/vector/url_utils';
4242

43-
var DEFAULT_HS_URL='http://my_server';
44-
var DEFAULT_IS_URL='http://my_is';
43+
const DEFAULT_HS_URL='http://my_server';
44+
const DEFAULT_IS_URL='http://my_is';
4545

46-
describe('loading:', function () {
46+
describe('loading:', function() {
4747
let parentDiv;
4848
let httpBackend;
4949

@@ -74,7 +74,7 @@ describe('loading:', function () {
7474
});
7575
});
7676

77-
afterEach(async function () {
77+
afterEach(async function() {
7878
console.log(`${Date.now()}: loading: afterEach`);
7979
if (parentDiv) {
8080
ReactDOM.unmountComponentAtNode(parentDiv);
@@ -112,12 +112,12 @@ describe('loading:', function () {
112112
toString: function() { return this.search + this.hash; },
113113
};
114114

115-
let tokenLoginCompleteDefer = Promise.defer();
115+
const tokenLoginCompleteDefer = Promise.defer();
116116
tokenLoginCompletePromise = tokenLoginCompleteDefer.promise;
117117

118118
function onNewScreen(screen) {
119119
console.log(Date.now() + " newscreen "+screen);
120-
var hash = '#/' + screen;
120+
const hash = '#/' + screen;
121121
windowLocation.hash = hash;
122122
console.log(Date.now() + " browser URI now "+ windowLocation);
123123
}
@@ -129,7 +129,7 @@ describe('loading:', function () {
129129
return {
130130
screen: fragparts.location.substring(1),
131131
params: fragparts.params,
132-
}
132+
};
133133
}
134134

135135
const MatrixChat = sdk.getComponent('structures.MatrixChat');
@@ -142,7 +142,7 @@ describe('loading:', function () {
142142

143143
PlatformPeg.set(new Platform());
144144

145-
var params = parseQs(windowLocation);
145+
const params = parseQs(windowLocation);
146146
matrixChat = ReactDOM.render(
147147
<MatrixChat
148148
onNewScreen={onNewScreen}
@@ -153,7 +153,7 @@ describe('loading:', function () {
153153
onTokenLoginCompleted={() => tokenLoginCompleteDefer.resolve()}
154154
initialScreenAfterLogin={getScreenFromLocation(windowLocation)}
155155
makeRegistrationUrl={() => {throw new Error('Not implemented');}}
156-
/>, parentDiv
156+
/>, parentDiv,
157157
);
158158
}
159159

@@ -179,7 +179,7 @@ describe('loading:', function () {
179179
}
180180

181181
describe("Clean load with no stored credentials:", function() {
182-
it('gives a login panel by default', function (done) {
182+
it('gives a login panel by default', function(done) {
183183
loadApp();
184184

185185
Promise.delay(1).then(() => {
@@ -257,7 +257,6 @@ describe('loading:', function () {
257257
}
258258
return completeLogin(matrixChat);
259259
}).then(() => {
260-
261260
// once the sync completes, we should have a room view
262261
ReactTestUtils.findRenderedComponentWithType(
263262
matrixChat, sdk.getComponent('structures.HomePage'));
@@ -356,7 +355,7 @@ describe('loading:', function () {
356355
});
357356
return httpBackend.flush();
358357
}).then(() => {
359-
return awaitSyncingSpinner(matrixChat)
358+
return awaitSyncingSpinner(matrixChat);
360359
}).then(() => {
361360
// we got a sync spinner - let the sync complete
362361
return expectAndAwaitSync();
@@ -380,7 +379,7 @@ describe('loading:', function () {
380379
it('shows a login view', function() {
381380
// we expect a single <Login> component
382381
ReactTestUtils.findRenderedComponentWithType(
383-
matrixChat, sdk.getComponent('structures.login.Login')
382+
matrixChat, sdk.getComponent('structures.login.Login'),
384383
);
385384

386385
// the only outstanding request should be a GET /login
@@ -408,7 +407,7 @@ describe('loading:', function () {
408407
});
409408

410409
describe('Guest auto-registration:', function() {
411-
it('shows a home page by default', function (done) {
410+
it('shows a home page by default', function(done) {
412411
loadApp();
413412

414413
Promise.delay(1).then(() => {
@@ -438,7 +437,7 @@ describe('loading:', function () {
438437
}).done(done, done);
439438
});
440439

441-
it('uses the last known homeserver to register with', function (done) {
440+
it('uses the last known homeserver to register with', function(done) {
442441
localStorage.setItem("mx_hs_url", "https://homeserver" );
443442
localStorage.setItem("mx_is_url", "https://idserver" );
444443

@@ -477,7 +476,7 @@ describe('loading:', function () {
477476

478477
it('shows a room view if we followed a room link', function(done) {
479478
loadApp({
480-
uriFragment: "#/room/!room:id"
479+
uriFragment: "#/room/!room:id",
481480
});
482481
Promise.delay(1).then(() => {
483482
// at this point, we're trying to do a guest registration;
@@ -547,7 +546,7 @@ describe('loading:', function () {
547546

548547
// we expect a single <Login> component
549548
ReactTestUtils.findRenderedComponentWithType(
550-
matrixChat, sdk.getComponent('structures.login.Login')
549+
matrixChat, sdk.getComponent('structures.login.Login'),
551550
);
552551
});
553552

@@ -580,7 +579,7 @@ describe('loading:', function () {
580579
});
581580

582581
describe('Token login:', function() {
583-
it('logs in successfully', function (done) {
582+
it('logs in successfully', function(done) {
584583
loadApp({
585584
queryString: "?loginToken=secretToken&homeserver=https%3A%2F%2Fhomeserver&identityServer=https%3A%2F%2Fidserver",
586585
});
@@ -658,7 +657,7 @@ describe('loading:', function () {
658657

659658
// assert that we are on the loading page
660659
function assertAtLoadingSpinner(matrixChat) {
661-
var domComponent = ReactDOM.findDOMNode(matrixChat);
660+
const domComponent = ReactDOM.findDOMNode(matrixChat);
662661
expect(domComponent.className).toEqual("mx_MatrixChat_splash");
663662

664663
// just the spinner
@@ -697,12 +696,12 @@ function awaitSyncingSpinner(matrixChat, retryLimit, retryCount) {
697696
}
698697

699698
function assertAtSyncingSpinner(matrixChat) {
700-
var domComponent = ReactDOM.findDOMNode(matrixChat);
699+
const domComponent = ReactDOM.findDOMNode(matrixChat);
701700
expect(domComponent.className).toEqual("mx_MatrixChat_splash");
702701

703702
ReactTestUtils.findRenderedComponentWithType(
704703
matrixChat, sdk.getComponent('elements.Spinner'));
705-
var logoutLink = ReactTestUtils.findRenderedDOMComponentWithTag(
704+
const logoutLink = ReactTestUtils.findRenderedDOMComponentWithTag(
706705
matrixChat, 'a');
707706
expect(logoutLink.text).toEqual("Logout");
708707
}

test/skin-sdk.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
* Skins the react-sdk with the vector components
55
*/
66

7-
var sdk = require('matrix-react-sdk');
7+
const sdk = require('matrix-react-sdk');
88
sdk.loadSkin(require('../src/component-index'));

test/test-utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Promise from 'bluebird';
88
* @param {Mocha.Context} context The test context
99
*/
1010
export function beforeEach(context) {
11-
var desc = context.currentTest.fullTitle();
11+
const desc = context.currentTest.fullTitle();
1212
console.log();
1313
console.log(desc);
1414
console.log(new Array(1 + desc.length).join("="));
@@ -22,7 +22,7 @@ export function beforeEach(context) {
2222
* returns true if the current environment supports webrtc
2323
*/
2424
export function browserSupportsWebRTC() {
25-
var n = global.window.navigator;
25+
const n = global.window.navigator;
2626
return n.getUserMedia || n.webkitGetUserMedia ||
2727
n.mozGetUserMedia;
2828
}

0 commit comments

Comments
 (0)