eslint --fix on test/

pull/7490/head
Aaron Raimist 2018-10-12 19:01:09 -05:00
parent 6abd1de8b8
commit 70fe4f67ee
No known key found for this signature in database
GPG Key ID: 37419210002890EF
5 changed files with 55 additions and 56 deletions

View File

@ -6,8 +6,8 @@
// ideally these unit tests could be run under nodejs rather than in a browser // ideally these unit tests could be run under nodejs rather than in a browser
// via karma, but having two separate test frameworks in the same project // via karma, but having two separate test frameworks in the same project
// seems confusing // seems confusing
var unit_tests = require.context('./unit-tests', true, /\.js$/); const unit_tests = require.context('./unit-tests', true, /\.js$/);
unit_tests.keys().forEach(unit_tests); unit_tests.keys().forEach(unit_tests);
var app_tests = require.context('./app-tests', true, /\.jsx?$/); const app_tests = require.context('./app-tests', true, /\.jsx?$/);
app_tests.keys().forEach(app_tests); app_tests.keys().forEach(app_tests);

View File

@ -21,36 +21,36 @@ import Platform from '../../src/vector/platform';
require('skin-sdk'); require('skin-sdk');
var jssdk = require('matrix-js-sdk'); const jssdk = require('matrix-js-sdk');
var sdk = require('matrix-react-sdk'); const sdk = require('matrix-react-sdk');
var peg = require('matrix-react-sdk/lib/MatrixClientPeg'); const peg = require('matrix-react-sdk/lib/MatrixClientPeg');
var dis = require('matrix-react-sdk/lib/dispatcher'); const dis = require('matrix-react-sdk/lib/dispatcher');
var PageTypes = require('matrix-react-sdk/lib/PageTypes'); const PageTypes = require('matrix-react-sdk/lib/PageTypes');
var MatrixChat = sdk.getComponent('structures.MatrixChat'); const MatrixChat = sdk.getComponent('structures.MatrixChat');
var RoomDirectory = sdk.getComponent('structures.RoomDirectory'); const RoomDirectory = sdk.getComponent('structures.RoomDirectory');
var RoomPreviewBar = sdk.getComponent('rooms.RoomPreviewBar'); const RoomPreviewBar = sdk.getComponent('rooms.RoomPreviewBar');
var RoomView = sdk.getComponent('structures.RoomView'); const RoomView = sdk.getComponent('structures.RoomView');
var React = require('react'); const React = require('react');
var ReactDOM = require('react-dom'); const ReactDOM = require('react-dom');
var ReactTestUtils = require('react-addons-test-utils'); const ReactTestUtils = require('react-addons-test-utils');
var expect = require('expect'); const expect = require('expect');
import Promise from 'bluebird'; import Promise from 'bluebird';
var test_utils = require('../test-utils'); const test_utils = require('../test-utils');
var MockHttpBackend = require('matrix-mock-request'); const MockHttpBackend = require('matrix-mock-request');
var HS_URL='http://localhost'; const HS_URL='http://localhost';
var IS_URL='http://localhost'; const IS_URL='http://localhost';
var USER_ID='@me:localhost'; const USER_ID='@me:localhost';
var ACCESS_TOKEN='access_token'; const ACCESS_TOKEN='access_token';
describe('joining a room', function() { describe('joining a room', function() {
describe('over federation', function() { describe('over federation', function() {
var parentDiv; let parentDiv;
var httpBackend; let httpBackend;
var matrixChat; let matrixChat;
beforeEach(function() { beforeEach(function() {
test_utils.beforeEach(this); test_utils.beforeEach(this);
@ -72,8 +72,8 @@ describe('joining a room', function () {
}); });
it('should not get stuck at a spinner', function() { it('should not get stuck at a spinner', function() {
var ROOM_ALIAS = '#alias:localhost'; const ROOM_ALIAS = '#alias:localhost';
var ROOM_ID = '!id:localhost'; const ROOM_ID = '!id:localhost';
httpBackend.when('GET', '/pushrules').respond(200, {}); httpBackend.when('GET', '/pushrules').respond(200, {});
httpBackend.when('POST', '/filter').respond(200, { filter_id: 'fid' }); httpBackend.when('POST', '/filter').respond(200, { filter_id: 'fid' });
@ -90,7 +90,7 @@ describe('joining a room', function () {
PlatformPeg.set(new Platform()); PlatformPeg.set(new Platform());
var mc = ( const mc = (
<MatrixChat config={{}} <MatrixChat config={{}}
makeRegistrationUrl={()=>{throw new Error("unimplemented");}} makeRegistrationUrl={()=>{throw new Error("unimplemented");}}
initialScreenAfterLogin={{ initialScreenAfterLogin={{
@ -100,7 +100,7 @@ describe('joining a room', function () {
); );
matrixChat = ReactDOM.render(mc, parentDiv); matrixChat = ReactDOM.render(mc, parentDiv);
var roomView; let roomView;
// wait for /sync to happen. This may take some time, as the client // wait for /sync to happen. This may take some time, as the client
// has to initialise indexeddb. // has to initialise indexeddb.
@ -118,11 +118,11 @@ describe('joining a room', function () {
}).then(() => { }).then(() => {
console.log(`${Date.now()} App made requests for directory view; switching to a room.`); console.log(`${Date.now()} App made requests for directory view; switching to a room.`);
var roomDir = ReactTestUtils.findRenderedComponentWithType( const roomDir = ReactTestUtils.findRenderedComponentWithType(
matrixChat, RoomDirectory); matrixChat, RoomDirectory);
// enter an alias in the input, and simulate enter // enter an alias in the input, and simulate enter
var input = ReactTestUtils.findRenderedDOMComponentWithTag( const input = ReactTestUtils.findRenderedDOMComponentWithTag(
roomDir, 'input'); roomDir, 'input');
input.value = ROOM_ALIAS; input.value = ROOM_ALIAS;
ReactTestUtils.Simulate.change(input); ReactTestUtils.Simulate.change(input);

View File

@ -40,8 +40,8 @@ import * as test_utils from '../test-utils';
import MockHttpBackend from 'matrix-mock-request'; import MockHttpBackend from 'matrix-mock-request';
import {parseQs, parseQsFromFragment} from '../../src/vector/url_utils'; import {parseQs, parseQsFromFragment} from '../../src/vector/url_utils';
var DEFAULT_HS_URL='http://my_server'; const DEFAULT_HS_URL='http://my_server';
var DEFAULT_IS_URL='http://my_is'; const DEFAULT_IS_URL='http://my_is';
describe('loading:', function() { describe('loading:', function() {
let parentDiv; let parentDiv;
@ -112,12 +112,12 @@ describe('loading:', function () {
toString: function() { return this.search + this.hash; }, toString: function() { return this.search + this.hash; },
}; };
let tokenLoginCompleteDefer = Promise.defer(); const tokenLoginCompleteDefer = Promise.defer();
tokenLoginCompletePromise = tokenLoginCompleteDefer.promise; tokenLoginCompletePromise = tokenLoginCompleteDefer.promise;
function onNewScreen(screen) { function onNewScreen(screen) {
console.log(Date.now() + " newscreen "+screen); console.log(Date.now() + " newscreen "+screen);
var hash = '#/' + screen; const hash = '#/' + screen;
windowLocation.hash = hash; windowLocation.hash = hash;
console.log(Date.now() + " browser URI now "+ windowLocation); console.log(Date.now() + " browser URI now "+ windowLocation);
} }
@ -129,7 +129,7 @@ describe('loading:', function () {
return { return {
screen: fragparts.location.substring(1), screen: fragparts.location.substring(1),
params: fragparts.params, params: fragparts.params,
} };
} }
const MatrixChat = sdk.getComponent('structures.MatrixChat'); const MatrixChat = sdk.getComponent('structures.MatrixChat');
@ -142,7 +142,7 @@ describe('loading:', function () {
PlatformPeg.set(new Platform()); PlatformPeg.set(new Platform());
var params = parseQs(windowLocation); const params = parseQs(windowLocation);
matrixChat = ReactDOM.render( matrixChat = ReactDOM.render(
<MatrixChat <MatrixChat
onNewScreen={onNewScreen} onNewScreen={onNewScreen}
@ -153,7 +153,7 @@ describe('loading:', function () {
onTokenLoginCompleted={() => tokenLoginCompleteDefer.resolve()} onTokenLoginCompleted={() => tokenLoginCompleteDefer.resolve()}
initialScreenAfterLogin={getScreenFromLocation(windowLocation)} initialScreenAfterLogin={getScreenFromLocation(windowLocation)}
makeRegistrationUrl={() => {throw new Error('Not implemented');}} makeRegistrationUrl={() => {throw new Error('Not implemented');}}
/>, parentDiv />, parentDiv,
); );
} }
@ -257,7 +257,6 @@ describe('loading:', function () {
} }
return completeLogin(matrixChat); return completeLogin(matrixChat);
}).then(() => { }).then(() => {
// once the sync completes, we should have a room view // once the sync completes, we should have a room view
ReactTestUtils.findRenderedComponentWithType( ReactTestUtils.findRenderedComponentWithType(
matrixChat, sdk.getComponent('structures.HomePage')); matrixChat, sdk.getComponent('structures.HomePage'));
@ -356,7 +355,7 @@ describe('loading:', function () {
}); });
return httpBackend.flush(); return httpBackend.flush();
}).then(() => { }).then(() => {
return awaitSyncingSpinner(matrixChat) return awaitSyncingSpinner(matrixChat);
}).then(() => { }).then(() => {
// we got a sync spinner - let the sync complete // we got a sync spinner - let the sync complete
return expectAndAwaitSync(); return expectAndAwaitSync();
@ -380,7 +379,7 @@ describe('loading:', function () {
it('shows a login view', function() { it('shows a login view', function() {
// we expect a single <Login> component // we expect a single <Login> component
ReactTestUtils.findRenderedComponentWithType( ReactTestUtils.findRenderedComponentWithType(
matrixChat, sdk.getComponent('structures.login.Login') matrixChat, sdk.getComponent('structures.login.Login'),
); );
// the only outstanding request should be a GET /login // the only outstanding request should be a GET /login
@ -477,7 +476,7 @@ describe('loading:', function () {
it('shows a room view if we followed a room link', function(done) { it('shows a room view if we followed a room link', function(done) {
loadApp({ loadApp({
uriFragment: "#/room/!room:id" uriFragment: "#/room/!room:id",
}); });
Promise.delay(1).then(() => { Promise.delay(1).then(() => {
// at this point, we're trying to do a guest registration; // at this point, we're trying to do a guest registration;
@ -547,7 +546,7 @@ describe('loading:', function () {
// we expect a single <Login> component // we expect a single <Login> component
ReactTestUtils.findRenderedComponentWithType( ReactTestUtils.findRenderedComponentWithType(
matrixChat, sdk.getComponent('structures.login.Login') matrixChat, sdk.getComponent('structures.login.Login'),
); );
}); });
@ -658,7 +657,7 @@ describe('loading:', function () {
// assert that we are on the loading page // assert that we are on the loading page
function assertAtLoadingSpinner(matrixChat) { function assertAtLoadingSpinner(matrixChat) {
var domComponent = ReactDOM.findDOMNode(matrixChat); const domComponent = ReactDOM.findDOMNode(matrixChat);
expect(domComponent.className).toEqual("mx_MatrixChat_splash"); expect(domComponent.className).toEqual("mx_MatrixChat_splash");
// just the spinner // just the spinner
@ -697,12 +696,12 @@ function awaitSyncingSpinner(matrixChat, retryLimit, retryCount) {
} }
function assertAtSyncingSpinner(matrixChat) { function assertAtSyncingSpinner(matrixChat) {
var domComponent = ReactDOM.findDOMNode(matrixChat); const domComponent = ReactDOM.findDOMNode(matrixChat);
expect(domComponent.className).toEqual("mx_MatrixChat_splash"); expect(domComponent.className).toEqual("mx_MatrixChat_splash");
ReactTestUtils.findRenderedComponentWithType( ReactTestUtils.findRenderedComponentWithType(
matrixChat, sdk.getComponent('elements.Spinner')); matrixChat, sdk.getComponent('elements.Spinner'));
var logoutLink = ReactTestUtils.findRenderedDOMComponentWithTag( const logoutLink = ReactTestUtils.findRenderedDOMComponentWithTag(
matrixChat, 'a'); matrixChat, 'a');
expect(logoutLink.text).toEqual("Logout"); expect(logoutLink.text).toEqual("Logout");
} }

View File

@ -4,5 +4,5 @@
* Skins the react-sdk with the vector components * Skins the react-sdk with the vector components
*/ */
var sdk = require('matrix-react-sdk'); const sdk = require('matrix-react-sdk');
sdk.loadSkin(require('../src/component-index')); sdk.loadSkin(require('../src/component-index'));

View File

@ -8,7 +8,7 @@ import Promise from 'bluebird';
* @param {Mocha.Context} context The test context * @param {Mocha.Context} context The test context
*/ */
export function beforeEach(context) { export function beforeEach(context) {
var desc = context.currentTest.fullTitle(); const desc = context.currentTest.fullTitle();
console.log(); console.log();
console.log(desc); console.log(desc);
console.log(new Array(1 + desc.length).join("=")); console.log(new Array(1 + desc.length).join("="));
@ -22,7 +22,7 @@ export function beforeEach(context) {
* returns true if the current environment supports webrtc * returns true if the current environment supports webrtc
*/ */
export function browserSupportsWebRTC() { export function browserSupportsWebRTC() {
var n = global.window.navigator; const n = global.window.navigator;
return n.getUserMedia || n.webkitGetUserMedia || return n.getUserMedia || n.webkitGetUserMedia ||
n.mozGetUserMedia; n.mozGetUserMedia;
} }