1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-08-09 08:42:50 +03:00

Remove dead code (#9035)

This commit is contained in:
Šimon Brandner
2022-07-11 07:52:44 +02:00
committed by GitHub
parent d1928d2cb3
commit 19e514d83c
28 changed files with 6 additions and 412 deletions

View File

@@ -1,31 +0,0 @@
/*
Copyright 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.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { textForLocation } from "../../../../src/components/views/location/shareLocation";
describe("LocationButton", () => {
describe("textForLocation", () => {
it("with no description, simply dumps URI and date", () => {
expect(textForLocation("geo:43.2,54.6", 12345, null)).toBe(
"Location geo:43.2,54.6 at 1970-01-01T00:00:12.345Z");
});
it("with a description, includes that in the text", () => {
expect(textForLocation("geo:12,43,3;u=2", 54321, "Me!")).toBe(
'Location "Me!" geo:12,43,3;u=2 at 1970-01-01T00:00:54.321Z');
});
});
});

View File

@@ -14,8 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { MatrixClient, MatrixEvent, Room } from "matrix-js-sdk/src/matrix";
import { Thread } from "matrix-js-sdk/src/models/thread";
import { MatrixEvent, Room } from "matrix-js-sdk/src/matrix";
import { mkMessage, MessageEventProps } from "./test-utils";
@@ -89,8 +88,3 @@ export const makeThreadEvents = ({
return { rootEvent, events };
};
export const makeThread = (client: MatrixClient, room: Room, props: MakeThreadEventsProps): Thread => {
const { rootEvent, events } = makeThreadEvents(props);
return new Thread(rootEvent.getId(), rootEvent, { initialEvents: events, room, client });
};

View File

@@ -14,20 +14,9 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { iterableDiff, iterableUnion, iterableIntersection } from "../../src/utils/iterables";
import { iterableDiff, iterableIntersection } from "../../src/utils/iterables";
describe('iterables', () => {
describe('iterableUnion', () => {
it('should return the union array', () => {
const a = [1, 2, 3];
const b = [1, 2, 4]; // note diff
const result = iterableUnion(a, b);
expect(result).toBeDefined();
expect(result).toHaveLength(4);
expect(result).toEqual([1, 2, 3, 4]);
});
});
describe('iterableIntersection', () => {
it('should return the intersection', () => {
const a = [1, 2, 3];

View File

@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { EnhancedMap, mapDiff, mapKeyChanges } from "../../src/utils/maps";
import { EnhancedMap, mapDiff } from "../../src/utils/maps";
describe('maps', () => {
describe('mapDiff', () => {
@@ -116,68 +116,6 @@ describe('maps', () => {
});
});
describe('mapKeyChanges', () => {
it('should indicate no changes for unchanged pointers', () => {
const a = new Map([[1, 1], [2, 2], [3, 3]]);
const result = mapKeyChanges(a, a);
expect(result).toBeDefined();
expect(result).toHaveLength(0);
});
it('should indicate no changes for unchanged maps with different pointers', () => {
const a = new Map([[1, 1], [2, 2], [3, 3]]);
const b = new Map([[1, 1], [2, 2], [3, 3]]);
const result = mapKeyChanges(a, b);
expect(result).toBeDefined();
expect(result).toHaveLength(0);
});
it('should indicate changes for added properties', () => {
const a = new Map([[1, 1], [2, 2], [3, 3]]);
const b = new Map([[1, 1], [2, 2], [3, 3], [4, 4]]);
const result = mapKeyChanges(a, b);
expect(result).toBeDefined();
expect(result).toHaveLength(1);
expect(result).toEqual([4]);
});
it('should indicate changes for removed properties', () => {
const a = new Map([[1, 1], [2, 2], [3, 3], [4, 4]]);
const b = new Map([[1, 1], [2, 2], [3, 3]]);
const result = mapKeyChanges(a, b);
expect(result).toBeDefined();
expect(result).toHaveLength(1);
expect(result).toEqual([4]);
});
it('should indicate changes for changed properties', () => {
const a = new Map([[1, 1], [2, 2], [3, 3], [4, 4]]);
const b = new Map([[1, 1], [2, 2], [3, 3], [4, 55]]);
const result = mapKeyChanges(a, b);
expect(result).toBeDefined();
expect(result).toHaveLength(1);
expect(result).toEqual([4]);
});
it('should indicate changes for properties with different pointers', () => {
const a = new Map([[1, {}]]); // {} always creates a new object
const b = new Map([[1, {}]]);
const result = mapKeyChanges(a, b);
expect(result).toBeDefined();
expect(result).toHaveLength(1);
expect(result).toEqual([1]);
});
it('should indicate changes for changed, added, and removed properties', () => {
const a = new Map([[1, 1], [2, 2], [3, 3]]);
const b = new Map([[1, 1], [2, 8], [4, 4]]); // note change
const result = mapKeyChanges(a, b);
expect(result).toBeDefined();
expect(result).toHaveLength(3);
expect(result).toEqual([3, 4, 2]); // order irrelevant, but the test cares
});
});
describe('EnhancedMap', () => {
// Most of these tests will make sure it implements the Map<K, V> class