Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions .eslintignore.errorfiles

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"start:all": "concurrently --kill-others-on-fail --prefix \"{time} [{name}]\" -n build,reskindex \"yarn start:build\" \"yarn reskindex:watch\"",
"start:build": "babel src -w -s -d lib --verbose --extensions \".ts,.js\"",
"lint": "yarn lint:types && yarn lint:js && yarn lint:style",
"lint:js": "eslint --max-warnings 0 --ignore-path .eslintignore.errorfiles src test",
"lint:js": "eslint --max-warnings 0 src test",
"lint:types": "tsc --noEmit --jsx react",
"lint:style": "stylelint 'res/css/**/*.scss'",
"test": "jest",
Expand Down
23 changes: 0 additions & 23 deletions scripts/generate-eslint-error-ignore-file

This file was deleted.

39 changes: 20 additions & 19 deletions test/components/structures/MessagePanel-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Copyright 2016 OpenMarket Ltd
Copyright 2019 The Matrix.org Foundation C.I.C.
Copyright 2019, 2021 The Matrix.org Foundation C.I.C.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -26,11 +26,11 @@ import { EventEmitter } from "events";
import sdk from '../../skinned-sdk';

const MessagePanel = sdk.getComponent('structures.MessagePanel');
import {MatrixClientPeg} from '../../../src/MatrixClientPeg';
import { MatrixClientPeg } from '../../../src/MatrixClientPeg';
import Matrix from 'matrix-js-sdk';

const test_utils = require('../../test-utils');
const mockclock = require('../../mock-clock');
const TestUtilsMatrix = require('../../test-utils');
import FakeTimers from '@sinonjs/fake-timers';

import Adapter from "@wojtekmaj/enzyme-adapter-react-17";
import { configure, mount } from "enzyme";
Expand Down Expand Up @@ -72,14 +72,14 @@ class WrappedMessagePanel extends React.Component {
}

describe('MessagePanel', function() {
const clock = mockclock.clock();
let clock = null;
const realSetTimeout = window.setTimeout;
const events = mkEvents();

beforeEach(function() {
test_utils.stubClient();
TestUtilsMatrix.stubClient();
client = MatrixClientPeg.get();
client.credentials = {userId: '@me:here'};
client.credentials = { userId: '@me:here' };

// HACK: We assume all settings want to be disabled
SettingsStore.getValue = jest.fn((arg) => {
Expand All @@ -90,14 +90,17 @@ describe('MessagePanel', function() {
});

afterEach(function() {
clock.uninstall();
if (clock) {
clock.uninstall();
clock = null;
}
});

function mkEvents() {
const events = [];
const ts0 = Date.now();
for (let i = 0; i < 10; i++) {
events.push(test_utils.mkMessage(
events.push(TestUtilsMatrix.mkMessage(
{
event: true, room: "!room:id", user: "@user:id",
ts: ts0 + i * 1000,
Expand All @@ -111,7 +114,7 @@ describe('MessagePanel', function() {
const events = [];
const ts0 = Date.parse('09 May 2004 00:12:00 GMT');
for (let i = 0; i < 10; i++) {
events.push(test_utils.mkMessage(
events.push(TestUtilsMatrix.mkMessage(
{
event: true, room: "!room:id", user: "@user:id",
ts: ts0 + i * 1000,
Expand All @@ -120,21 +123,20 @@ describe('MessagePanel', function() {
return events;
}


// make a collection of events with some member events that should be collapsed
// with a MemberEventListSummary
function mkMelsEvents() {
const events = [];
const ts0 = Date.now();

let i = 0;
events.push(test_utils.mkMessage({
events.push(TestUtilsMatrix.mkMessage({
event: true, room: "!room:id", user: "@user:id",
ts: ts0 + ++i * 1000,
}));

for (i = 0; i < 10; i++) {
events.push(test_utils.mkMembership({
events.push(TestUtilsMatrix.mkMembership({
event: true, room: "!room:id", user: "@user:id",
target: {
userId: "@user:id",
Expand All @@ -151,7 +153,7 @@ describe('MessagePanel', function() {
}));
}

events.push(test_utils.mkMessage({
events.push(TestUtilsMatrix.mkMessage({
event: true, room: "!room:id", user: "@user:id",
ts: ts0 + ++i*1000,
}));
Expand All @@ -167,7 +169,7 @@ describe('MessagePanel', function() {
let i = 0;

for (i = 0; i < 10; i++) {
events.push(test_utils.mkMembership({
events.push(TestUtilsMatrix.mkMembership({
event: true, room: "!room:id", user: "@user:id",
target: {
userId: "@user:id",
Expand All @@ -189,8 +191,8 @@ describe('MessagePanel', function() {

// A list of room creation, encryption, and invite events.
function mkCreationEvents() {
const mkEvent = test_utils.mkEvent;
const mkMembership = test_utils.mkMembership;
const mkEvent = TestUtilsMatrix.mkEvent;
const mkMembership = TestUtilsMatrix.mkMembership;
const roomId = "!someroom";
const alice = "@alice:example.org";
const ts0 = Date.now();
Expand Down Expand Up @@ -363,8 +365,7 @@ describe('MessagePanel', function() {

it('shows a ghost read-marker when the read-marker moves', function(done) {
// fake the clock so that we can test the velocity animation.
clock.install();
clock.mockDate();
clock = FakeTimers.install();

const parentDiv = document.createElement('div');

Expand Down
16 changes: 8 additions & 8 deletions test/components/views/dialogs/InteractiveAuthDialog-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import ReactTestUtils from 'react-dom/test-utils';
import MatrixReactTestUtils from 'matrix-react-test-utils';

import sdk from '../../../skinned-sdk';
import {MatrixClientPeg} from '../../../../src/MatrixClientPeg';
import { MatrixClientPeg } from '../../../../src/MatrixClientPeg';

import * as test_utils from '../../../test-utils';
import {sleep} from "../../../../src/utils/promise";
import * as TestUtilsMatrix from '../../../test-utils';
import { sleep } from "../../../../src/utils/promise";

const InteractiveAuthDialog = sdk.getComponent(
'views.dialogs.InteractiveAuthDialog',
Expand All @@ -33,7 +33,7 @@ describe('InteractiveAuthDialog', function() {
let parentDiv;

beforeEach(function() {
test_utils.stubClient();
TestUtilsMatrix.stubClient();
parentDiv = document.createElement('div');
document.body.appendChild(parentDiv);
});
Expand All @@ -45,19 +45,19 @@ describe('InteractiveAuthDialog', function() {

it('Should successfully complete a password flow', function() {
const onFinished = jest.fn();
const doRequest = jest.fn().mockResolvedValue({a: 1});
const doRequest = jest.fn().mockResolvedValue({ a: 1 });

// tell the stub matrixclient to return a real userid
const client = MatrixClientPeg.get();
client.credentials = {userId: "@user:id"};
client.credentials = { userId: "@user:id" };

const dlg = ReactDOM.render(
<InteractiveAuthDialog
matrixClient={client}
authData={{
session: "sess",
flows: [
{"stages": ["m.login.password"]},
{ "stages": ["m.login.password"] },
],
}}
makeRequest={doRequest}
Expand Down Expand Up @@ -105,7 +105,7 @@ describe('InteractiveAuthDialog', function() {
return sleep(1);
}).then(sleep(1)).then(() => {
expect(onFinished).toBeCalledTimes(1);
expect(onFinished).toBeCalledWith(true, {a: 1});
expect(onFinished).toBeCalledWith(true, { a: 1 });
});
});
});
Loading