eslint --fix on test/
parent
6abd1de8b8
commit
70fe4f67ee
|
@ -6,8 +6,8 @@
|
|||
// 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
|
||||
// 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);
|
||||
|
||||
var app_tests = require.context('./app-tests', true, /\.jsx?$/);
|
||||
const app_tests = require.context('./app-tests', true, /\.jsx?$/);
|
||||
app_tests.keys().forEach(app_tests);
|
||||
|
|
|
@ -21,36 +21,36 @@ import Platform from '../../src/vector/platform';
|
|||
|
||||
require('skin-sdk');
|
||||
|
||||
var jssdk = require('matrix-js-sdk');
|
||||
const jssdk = require('matrix-js-sdk');
|
||||
|
||||
var sdk = require('matrix-react-sdk');
|
||||
var peg = require('matrix-react-sdk/lib/MatrixClientPeg');
|
||||
var dis = require('matrix-react-sdk/lib/dispatcher');
|
||||
var PageTypes = require('matrix-react-sdk/lib/PageTypes');
|
||||
var MatrixChat = sdk.getComponent('structures.MatrixChat');
|
||||
var RoomDirectory = sdk.getComponent('structures.RoomDirectory');
|
||||
var RoomPreviewBar = sdk.getComponent('rooms.RoomPreviewBar');
|
||||
var RoomView = sdk.getComponent('structures.RoomView');
|
||||
const sdk = require('matrix-react-sdk');
|
||||
const peg = require('matrix-react-sdk/lib/MatrixClientPeg');
|
||||
const dis = require('matrix-react-sdk/lib/dispatcher');
|
||||
const PageTypes = require('matrix-react-sdk/lib/PageTypes');
|
||||
const MatrixChat = sdk.getComponent('structures.MatrixChat');
|
||||
const RoomDirectory = sdk.getComponent('structures.RoomDirectory');
|
||||
const RoomPreviewBar = sdk.getComponent('rooms.RoomPreviewBar');
|
||||
const RoomView = sdk.getComponent('structures.RoomView');
|
||||
|
||||
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 test_utils = require('../test-utils');
|
||||
var MockHttpBackend = require('matrix-mock-request');
|
||||
const test_utils = require('../test-utils');
|
||||
const MockHttpBackend = require('matrix-mock-request');
|
||||
|
||||
var HS_URL='http://localhost';
|
||||
var IS_URL='http://localhost';
|
||||
var USER_ID='@me:localhost';
|
||||
var ACCESS_TOKEN='access_token';
|
||||
const HS_URL='http://localhost';
|
||||
const IS_URL='http://localhost';
|
||||
const USER_ID='@me:localhost';
|
||||
const ACCESS_TOKEN='access_token';
|
||||
|
||||
describe('joining a room', function () {
|
||||
describe('over federation', function () {
|
||||
var parentDiv;
|
||||
var httpBackend;
|
||||
var matrixChat;
|
||||
describe('joining a room', function() {
|
||||
describe('over federation', function() {
|
||||
let parentDiv;
|
||||
let httpBackend;
|
||||
let matrixChat;
|
||||
|
||||
beforeEach(function() {
|
||||
test_utils.beforeEach(this);
|
||||
|
@ -72,8 +72,8 @@ describe('joining a room', function () {
|
|||
});
|
||||
|
||||
it('should not get stuck at a spinner', function() {
|
||||
var ROOM_ALIAS = '#alias:localhost';
|
||||
var ROOM_ID = '!id:localhost';
|
||||
const ROOM_ALIAS = '#alias:localhost';
|
||||
const ROOM_ID = '!id:localhost';
|
||||
|
||||
httpBackend.when('GET', '/pushrules').respond(200, {});
|
||||
httpBackend.when('POST', '/filter').respond(200, { filter_id: 'fid' });
|
||||
|
@ -90,7 +90,7 @@ describe('joining a room', function () {
|
|||
|
||||
PlatformPeg.set(new Platform());
|
||||
|
||||
var mc = (
|
||||
const mc = (
|
||||
<MatrixChat config={{}}
|
||||
makeRegistrationUrl={()=>{throw new Error("unimplemented");}}
|
||||
initialScreenAfterLogin={{
|
||||
|
@ -100,7 +100,7 @@ describe('joining a room', function () {
|
|||
);
|
||||
matrixChat = ReactDOM.render(mc, parentDiv);
|
||||
|
||||
var roomView;
|
||||
let roomView;
|
||||
|
||||
// wait for /sync to happen. This may take some time, as the client
|
||||
// has to initialise indexeddb.
|
||||
|
@ -118,11 +118,11 @@ describe('joining a room', function () {
|
|||
}).then(() => {
|
||||
console.log(`${Date.now()} App made requests for directory view; switching to a room.`);
|
||||
|
||||
var roomDir = ReactTestUtils.findRenderedComponentWithType(
|
||||
const roomDir = ReactTestUtils.findRenderedComponentWithType(
|
||||
matrixChat, RoomDirectory);
|
||||
|
||||
// enter an alias in the input, and simulate enter
|
||||
var input = ReactTestUtils.findRenderedDOMComponentWithTag(
|
||||
const input = ReactTestUtils.findRenderedDOMComponentWithTag(
|
||||
roomDir, 'input');
|
||||
input.value = ROOM_ALIAS;
|
||||
ReactTestUtils.Simulate.change(input);
|
||||
|
|
|
@ -40,10 +40,10 @@ import * as test_utils from '../test-utils';
|
|||
import MockHttpBackend from 'matrix-mock-request';
|
||||
import {parseQs, parseQsFromFragment} from '../../src/vector/url_utils';
|
||||
|
||||
var DEFAULT_HS_URL='http://my_server';
|
||||
var DEFAULT_IS_URL='http://my_is';
|
||||
const DEFAULT_HS_URL='http://my_server';
|
||||
const DEFAULT_IS_URL='http://my_is';
|
||||
|
||||
describe('loading:', function () {
|
||||
describe('loading:', function() {
|
||||
let parentDiv;
|
||||
let httpBackend;
|
||||
|
||||
|
@ -74,7 +74,7 @@ describe('loading:', function () {
|
|||
});
|
||||
});
|
||||
|
||||
afterEach(async function () {
|
||||
afterEach(async function() {
|
||||
console.log(`${Date.now()}: loading: afterEach`);
|
||||
if (parentDiv) {
|
||||
ReactDOM.unmountComponentAtNode(parentDiv);
|
||||
|
@ -112,12 +112,12 @@ describe('loading:', function () {
|
|||
toString: function() { return this.search + this.hash; },
|
||||
};
|
||||
|
||||
let tokenLoginCompleteDefer = Promise.defer();
|
||||
const tokenLoginCompleteDefer = Promise.defer();
|
||||
tokenLoginCompletePromise = tokenLoginCompleteDefer.promise;
|
||||
|
||||
function onNewScreen(screen) {
|
||||
console.log(Date.now() + " newscreen "+screen);
|
||||
var hash = '#/' + screen;
|
||||
const hash = '#/' + screen;
|
||||
windowLocation.hash = hash;
|
||||
console.log(Date.now() + " browser URI now "+ windowLocation);
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ describe('loading:', function () {
|
|||
return {
|
||||
screen: fragparts.location.substring(1),
|
||||
params: fragparts.params,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const MatrixChat = sdk.getComponent('structures.MatrixChat');
|
||||
|
@ -142,7 +142,7 @@ describe('loading:', function () {
|
|||
|
||||
PlatformPeg.set(new Platform());
|
||||
|
||||
var params = parseQs(windowLocation);
|
||||
const params = parseQs(windowLocation);
|
||||
matrixChat = ReactDOM.render(
|
||||
<MatrixChat
|
||||
onNewScreen={onNewScreen}
|
||||
|
@ -153,7 +153,7 @@ describe('loading:', function () {
|
|||
onTokenLoginCompleted={() => tokenLoginCompleteDefer.resolve()}
|
||||
initialScreenAfterLogin={getScreenFromLocation(windowLocation)}
|
||||
makeRegistrationUrl={() => {throw new Error('Not implemented');}}
|
||||
/>, parentDiv
|
||||
/>, parentDiv,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ describe('loading:', function () {
|
|||
}
|
||||
|
||||
describe("Clean load with no stored credentials:", function() {
|
||||
it('gives a login panel by default', function (done) {
|
||||
it('gives a login panel by default', function(done) {
|
||||
loadApp();
|
||||
|
||||
Promise.delay(1).then(() => {
|
||||
|
@ -257,7 +257,6 @@ describe('loading:', function () {
|
|||
}
|
||||
return completeLogin(matrixChat);
|
||||
}).then(() => {
|
||||
|
||||
// once the sync completes, we should have a room view
|
||||
ReactTestUtils.findRenderedComponentWithType(
|
||||
matrixChat, sdk.getComponent('structures.HomePage'));
|
||||
|
@ -356,7 +355,7 @@ describe('loading:', function () {
|
|||
});
|
||||
return httpBackend.flush();
|
||||
}).then(() => {
|
||||
return awaitSyncingSpinner(matrixChat)
|
||||
return awaitSyncingSpinner(matrixChat);
|
||||
}).then(() => {
|
||||
// we got a sync spinner - let the sync complete
|
||||
return expectAndAwaitSync();
|
||||
|
@ -380,7 +379,7 @@ describe('loading:', function () {
|
|||
it('shows a login view', function() {
|
||||
// we expect a single <Login> component
|
||||
ReactTestUtils.findRenderedComponentWithType(
|
||||
matrixChat, sdk.getComponent('structures.login.Login')
|
||||
matrixChat, sdk.getComponent('structures.login.Login'),
|
||||
);
|
||||
|
||||
// the only outstanding request should be a GET /login
|
||||
|
@ -408,7 +407,7 @@ describe('loading:', function () {
|
|||
});
|
||||
|
||||
describe('Guest auto-registration:', function() {
|
||||
it('shows a home page by default', function (done) {
|
||||
it('shows a home page by default', function(done) {
|
||||
loadApp();
|
||||
|
||||
Promise.delay(1).then(() => {
|
||||
|
@ -438,7 +437,7 @@ describe('loading:', function () {
|
|||
}).done(done, done);
|
||||
});
|
||||
|
||||
it('uses the last known homeserver to register with', function (done) {
|
||||
it('uses the last known homeserver to register with', function(done) {
|
||||
localStorage.setItem("mx_hs_url", "https://homeserver" );
|
||||
localStorage.setItem("mx_is_url", "https://idserver" );
|
||||
|
||||
|
@ -477,7 +476,7 @@ describe('loading:', function () {
|
|||
|
||||
it('shows a room view if we followed a room link', function(done) {
|
||||
loadApp({
|
||||
uriFragment: "#/room/!room:id"
|
||||
uriFragment: "#/room/!room:id",
|
||||
});
|
||||
Promise.delay(1).then(() => {
|
||||
// at this point, we're trying to do a guest registration;
|
||||
|
@ -547,7 +546,7 @@ describe('loading:', function () {
|
|||
|
||||
// we expect a single <Login> component
|
||||
ReactTestUtils.findRenderedComponentWithType(
|
||||
matrixChat, sdk.getComponent('structures.login.Login')
|
||||
matrixChat, sdk.getComponent('structures.login.Login'),
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -580,7 +579,7 @@ describe('loading:', function () {
|
|||
});
|
||||
|
||||
describe('Token login:', function() {
|
||||
it('logs in successfully', function (done) {
|
||||
it('logs in successfully', function(done) {
|
||||
loadApp({
|
||||
queryString: "?loginToken=secretToken&homeserver=https%3A%2F%2Fhomeserver&identityServer=https%3A%2F%2Fidserver",
|
||||
});
|
||||
|
@ -658,7 +657,7 @@ describe('loading:', function () {
|
|||
|
||||
// assert that we are on the loading page
|
||||
function assertAtLoadingSpinner(matrixChat) {
|
||||
var domComponent = ReactDOM.findDOMNode(matrixChat);
|
||||
const domComponent = ReactDOM.findDOMNode(matrixChat);
|
||||
expect(domComponent.className).toEqual("mx_MatrixChat_splash");
|
||||
|
||||
// just the spinner
|
||||
|
@ -697,12 +696,12 @@ function awaitSyncingSpinner(matrixChat, retryLimit, retryCount) {
|
|||
}
|
||||
|
||||
function assertAtSyncingSpinner(matrixChat) {
|
||||
var domComponent = ReactDOM.findDOMNode(matrixChat);
|
||||
const domComponent = ReactDOM.findDOMNode(matrixChat);
|
||||
expect(domComponent.className).toEqual("mx_MatrixChat_splash");
|
||||
|
||||
ReactTestUtils.findRenderedComponentWithType(
|
||||
matrixChat, sdk.getComponent('elements.Spinner'));
|
||||
var logoutLink = ReactTestUtils.findRenderedDOMComponentWithTag(
|
||||
const logoutLink = ReactTestUtils.findRenderedDOMComponentWithTag(
|
||||
matrixChat, 'a');
|
||||
expect(logoutLink.text).toEqual("Logout");
|
||||
}
|
||||
|
|
|
@ -4,5 +4,5 @@
|
|||
* 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'));
|
||||
|
|
|
@ -8,7 +8,7 @@ import Promise from 'bluebird';
|
|||
* @param {Mocha.Context} context The test context
|
||||
*/
|
||||
export function beforeEach(context) {
|
||||
var desc = context.currentTest.fullTitle();
|
||||
const desc = context.currentTest.fullTitle();
|
||||
console.log();
|
||||
console.log(desc);
|
||||
console.log(new Array(1 + desc.length).join("="));
|
||||
|
@ -22,7 +22,7 @@ export function beforeEach(context) {
|
|||
* returns true if the current environment supports webrtc
|
||||
*/
|
||||
export function browserSupportsWebRTC() {
|
||||
var n = global.window.navigator;
|
||||
const n = global.window.navigator;
|
||||
return n.getUserMedia || n.webkitGetUserMedia ||
|
||||
n.mozGetUserMedia;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue