You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-06 12:02:40 +03:00
de-lint
This commit is contained in:
@@ -4,10 +4,11 @@ import { Filter } from "../../src/filter";
|
|||||||
import { DEFAULT_TREE_POWER_LEVELS_TEMPLATE } from "../../src/models/MSC3089TreeSpace";
|
import { DEFAULT_TREE_POWER_LEVELS_TEMPLATE } from "../../src/models/MSC3089TreeSpace";
|
||||||
import {
|
import {
|
||||||
EventType,
|
EventType,
|
||||||
RoomCreateTypeField, RoomType,
|
RoomCreateTypeField,
|
||||||
|
RoomType,
|
||||||
UNSTABLE_MSC3088_ENABLED,
|
UNSTABLE_MSC3088_ENABLED,
|
||||||
UNSTABLE_MSC3088_PURPOSE,
|
UNSTABLE_MSC3088_PURPOSE,
|
||||||
UNSTABLE_MSC3089_TREE_SUBTYPE
|
UNSTABLE_MSC3089_TREE_SUBTYPE,
|
||||||
} from "../../src/@types/event";
|
} from "../../src/@types/event";
|
||||||
import { MEGOLM_ALGORITHM } from "../../src/crypto/olmlib";
|
import { MEGOLM_ALGORITHM } from "../../src/crypto/olmlib";
|
||||||
import { MatrixEvent } from "../../src/models/event";
|
import { MatrixEvent } from "../../src/models/event";
|
||||||
|
@@ -70,7 +70,8 @@ describe("MSC3089Branch", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to delete the file', async () => {
|
it('should be able to delete the file', async () => {
|
||||||
const stateFn = jest.fn().mockImplementation((roomId: string, eventType: string, content: any, stateKey: string) => {
|
const stateFn = jest.fn()
|
||||||
|
.mockImplementation((roomId: string, eventType: string, content: any, stateKey: string) => {
|
||||||
expect(roomId).toEqual(branchRoomId);
|
expect(roomId).toEqual(branchRoomId);
|
||||||
expect(eventType).toEqual(UNSTABLE_MSC3089_BRANCH.unstable); // test that we're definitely using the unstable value
|
expect(eventType).toEqual(UNSTABLE_MSC3089_BRANCH.unstable); // test that we're definitely using the unstable value
|
||||||
expect(content).toMatchObject({});
|
expect(content).toMatchObject({});
|
||||||
@@ -107,7 +108,8 @@ describe("MSC3089Branch", () => {
|
|||||||
it('should be able to change its name', async () => {
|
it('should be able to change its name', async () => {
|
||||||
const name = "My File.txt";
|
const name = "My File.txt";
|
||||||
indexEvent.getContent = () => ({ active: true, retained: true });
|
indexEvent.getContent = () => ({ active: true, retained: true });
|
||||||
const stateFn = jest.fn().mockImplementation((roomId: string, eventType: string, content: any, stateKey: string) => {
|
const stateFn = jest.fn()
|
||||||
|
.mockImplementation((roomId: string, eventType: string, content: any, stateKey: string) => {
|
||||||
expect(roomId).toEqual(branchRoomId);
|
expect(roomId).toEqual(branchRoomId);
|
||||||
expect(eventType).toEqual(UNSTABLE_MSC3089_BRANCH.unstable); // test that we're definitely using the unstable value
|
expect(eventType).toEqual(UNSTABLE_MSC3089_BRANCH.unstable); // test that we're definitely using the unstable value
|
||||||
expect(content).toMatchObject({
|
expect(content).toMatchObject({
|
||||||
|
@@ -83,7 +83,8 @@ describe("MSC3089TreeSpace", () => {
|
|||||||
|
|
||||||
it('should support setting the name of the space', async () => {
|
it('should support setting the name of the space', async () => {
|
||||||
const newName = "NEW NAME";
|
const newName = "NEW NAME";
|
||||||
const fn = jest.fn().mockImplementation((stateRoomId: string, eventType: EventType, content: any, stateKey: string) => {
|
const fn = jest.fn()
|
||||||
|
.mockImplementation((stateRoomId: string, eventType: EventType, content: any, stateKey: string) => {
|
||||||
expect(stateRoomId).toEqual(roomId);
|
expect(stateRoomId).toEqual(roomId);
|
||||||
expect(eventType).toEqual(EventType.RoomName);
|
expect(eventType).toEqual(EventType.RoomName);
|
||||||
expect(stateKey).toEqual("");
|
expect(stateKey).toEqual("");
|
||||||
@@ -109,7 +110,8 @@ describe("MSC3089TreeSpace", () => {
|
|||||||
|
|
||||||
async function evaluatePowerLevels(pls: any, role: TreePermissions, expectedPl: number) {
|
async function evaluatePowerLevels(pls: any, role: TreePermissions, expectedPl: number) {
|
||||||
makePowerLevels(pls);
|
makePowerLevels(pls);
|
||||||
const fn = jest.fn().mockImplementation((stateRoomId: string, eventType: EventType, content: any, stateKey: string) => {
|
const fn = jest.fn()
|
||||||
|
.mockImplementation((stateRoomId: string, eventType: EventType, content: any, stateKey: string) => {
|
||||||
expect(stateRoomId).toEqual(roomId);
|
expect(stateRoomId).toEqual(roomId);
|
||||||
expect(eventType).toEqual(EventType.RoomPowerLevels);
|
expect(eventType).toEqual(EventType.RoomPowerLevels);
|
||||||
expect(stateKey).toEqual("");
|
expect(stateKey).toEqual("");
|
||||||
@@ -155,7 +157,7 @@ describe("MSC3089TreeSpace", () => {
|
|||||||
users_default: 1024,
|
users_default: 1024,
|
||||||
users: {
|
users: {
|
||||||
[targetUser]: 2222,
|
[targetUser]: 2222,
|
||||||
}
|
},
|
||||||
}, TreePermissions.Viewer, 1024);
|
}, TreePermissions.Viewer, 1024);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -165,7 +167,7 @@ describe("MSC3089TreeSpace", () => {
|
|||||||
events_default: 1024,
|
events_default: 1024,
|
||||||
users: {
|
users: {
|
||||||
[targetUser]: 5,
|
[targetUser]: 5,
|
||||||
}
|
},
|
||||||
}, TreePermissions.Editor, 1024);
|
}, TreePermissions.Editor, 1024);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -199,7 +201,8 @@ describe("MSC3089TreeSpace", () => {
|
|||||||
expect(name).toEqual(subspaceName);
|
expect(name).toEqual(subspaceName);
|
||||||
return new MSC3089TreeSpace(client, subspaceId);
|
return new MSC3089TreeSpace(client, subspaceId);
|
||||||
});
|
});
|
||||||
const sendStateFn = jest.fn().mockImplementation(async (roomId: string, eventType: EventType, content: any, stateKey: string) => {
|
const sendStateFn = jest.fn()
|
||||||
|
.mockImplementation(async (roomId: string, eventType: EventType, content: any, stateKey: string) => {
|
||||||
expect([tree.roomId, subspaceId]).toContain(roomId);
|
expect([tree.roomId, subspaceId]).toContain(roomId);
|
||||||
if (roomId === subspaceId) {
|
if (roomId === subspaceId) {
|
||||||
expect(eventType).toEqual(EventType.SpaceParent);
|
expect(eventType).toEqual(EventType.SpaceParent);
|
||||||
@@ -311,7 +314,7 @@ describe("MSC3089TreeSpace", () => {
|
|||||||
|
|
||||||
// ensure we don't kick ourselves
|
// ensure we don't kick ourselves
|
||||||
{ getContent: () => ({ membership: "join" }), getStateKey: () => selfUserId },
|
{ getContent: () => ({ membership: "join" }), getStateKey: () => selfUserId },
|
||||||
]
|
];
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -361,7 +364,7 @@ describe("MSC3089TreeSpace", () => {
|
|||||||
getType: () => EventType.SpaceParent,
|
getType: () => EventType.SpaceParent,
|
||||||
getStateKey: () => tree.roomId,
|
getStateKey: () => tree.roomId,
|
||||||
getContent: () => ({
|
getContent: () => ({
|
||||||
via: [staticDomain]
|
via: [staticDomain],
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -408,7 +411,12 @@ describe("MSC3089TreeSpace", () => {
|
|||||||
roomId: tree.roomId,
|
roomId: tree.roomId,
|
||||||
currentState: {
|
currentState: {
|
||||||
getStateEvents: (eventType: EventType, stateKey?: string) => {
|
getStateEvents: (eventType: EventType, stateKey?: string) => {
|
||||||
expect([EventType.SpaceChild, EventType.RoomCreate, EventType.SpaceParent]).toContain(eventType);
|
expect([
|
||||||
|
EventType.SpaceChild,
|
||||||
|
EventType.RoomCreate,
|
||||||
|
EventType.SpaceParent,
|
||||||
|
]).toContain(eventType);
|
||||||
|
|
||||||
if (eventType === EventType.RoomCreate) {
|
if (eventType === EventType.RoomCreate) {
|
||||||
expect(stateKey).toEqual("");
|
expect(stateKey).toEqual("");
|
||||||
return parentState.filter(e => e.getType() === EventType.RoomCreate)[0];
|
return parentState.filter(e => e.getType() === EventType.RoomCreate)[0];
|
||||||
@@ -429,7 +437,8 @@ describe("MSC3089TreeSpace", () => {
|
|||||||
(<any>tree).room = parentRoom; // override readonly
|
(<any>tree).room = parentRoom; // override readonly
|
||||||
client.getRoom = (r) => rooms[r];
|
client.getRoom = (r) => rooms[r];
|
||||||
|
|
||||||
clientSendStateFn = jest.fn().mockImplementation((roomId: string, eventType: EventType, content: any, stateKey: string) => {
|
clientSendStateFn = jest.fn()
|
||||||
|
.mockImplementation((roomId: string, eventType: EventType, content: any, stateKey: string) => {
|
||||||
expect(roomId).toEqual(tree.roomId);
|
expect(roomId).toEqual(tree.roomId);
|
||||||
expect(eventType).toEqual(EventType.SpaceChild);
|
expect(eventType).toEqual(EventType.SpaceChild);
|
||||||
expect(content).toMatchObject(expect.objectContaining({
|
expect(content).toMatchObject(expect.objectContaining({
|
||||||
@@ -652,7 +661,7 @@ describe("MSC3089TreeSpace", () => {
|
|||||||
const d = "!d:example.org";
|
const d = "!d:example.org";
|
||||||
|
|
||||||
// Add in reverse order to make sure it gets ordered correctly
|
// Add in reverse order to make sure it gets ordered correctly
|
||||||
addSubspace(d, 4, "Z")
|
addSubspace(d, 4, "Z");
|
||||||
addSubspace(c, 3, "X");
|
addSubspace(c, 3, "X");
|
||||||
addSubspace(b, 2, "V");
|
addSubspace(b, 2, "V");
|
||||||
addSubspace(a, 1, "T");
|
addSubspace(a, 1, "T");
|
||||||
@@ -681,7 +690,7 @@ describe("MSC3089TreeSpace", () => {
|
|||||||
const d = "!d:example.org";
|
const d = "!d:example.org";
|
||||||
|
|
||||||
// Add in reverse order to make sure it gets ordered correctly
|
// Add in reverse order to make sure it gets ordered correctly
|
||||||
addSubspace(d, 4, "Z")
|
addSubspace(d, 4, "Z");
|
||||||
addSubspace(c, 3, "X");
|
addSubspace(c, 3, "X");
|
||||||
addSubspace(b, 2, "V");
|
addSubspace(b, 2, "V");
|
||||||
addSubspace(a, 1, "T");
|
addSubspace(a, 1, "T");
|
||||||
@@ -710,7 +719,7 @@ describe("MSC3089TreeSpace", () => {
|
|||||||
const d = "!d:example.org";
|
const d = "!d:example.org";
|
||||||
|
|
||||||
// Add in reverse order to make sure it gets ordered correctly
|
// Add in reverse order to make sure it gets ordered correctly
|
||||||
addSubspace(d, 4)
|
addSubspace(d, 4);
|
||||||
addSubspace(c, 3);
|
addSubspace(c, 3);
|
||||||
addSubspace(b, 2, "V");
|
addSubspace(b, 2, "V");
|
||||||
addSubspace(a, 1, "T");
|
addSubspace(a, 1, "T");
|
||||||
@@ -775,7 +784,8 @@ describe("MSC3089TreeSpace", () => {
|
|||||||
});
|
});
|
||||||
client.sendMessage = sendMsgFn;
|
client.sendMessage = sendMsgFn;
|
||||||
|
|
||||||
const sendStateFn = jest.fn().mockImplementation((roomId: string, eventType: string, content: any, stateKey: string) => {
|
const sendStateFn = jest.fn()
|
||||||
|
.mockImplementation((roomId: string, eventType: string, content: any, stateKey: string) => {
|
||||||
expect(roomId).toEqual(tree.roomId);
|
expect(roomId).toEqual(tree.roomId);
|
||||||
expect(eventType).toEqual(UNSTABLE_MSC3089_BRANCH.unstable); // test to ensure we're definitely using unstable
|
expect(eventType).toEqual(UNSTABLE_MSC3089_BRANCH.unstable); // test to ensure we're definitely using unstable
|
||||||
expect(stateKey).toEqual(fileEventId);
|
expect(stateKey).toEqual(fileEventId);
|
||||||
|
@@ -4,8 +4,9 @@ import {
|
|||||||
averageBetweenStrings,
|
averageBetweenStrings,
|
||||||
baseToString,
|
baseToString,
|
||||||
DEFAULT_ALPHABET,
|
DEFAULT_ALPHABET,
|
||||||
nextString, prevString,
|
nextString,
|
||||||
stringToBase
|
prevString,
|
||||||
|
stringToBase,
|
||||||
} from "../../src/utils";
|
} from "../../src/utils";
|
||||||
|
|
||||||
describe("utils", function() {
|
describe("utils", function() {
|
||||||
@@ -270,7 +271,9 @@ describe("utils", function() {
|
|||||||
|
|
||||||
describe('DEFAULT_ALPHABET', () => {
|
describe('DEFAULT_ALPHABET', () => {
|
||||||
it('should be usefully printable ASCII in order', () => {
|
it('should be usefully printable ASCII in order', () => {
|
||||||
expect(DEFAULT_ALPHABET).toEqual(" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~");
|
expect(DEFAULT_ALPHABET).toEqual(
|
||||||
|
" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -74,9 +74,9 @@ export interface ICreateRoomOpts {
|
|||||||
name?: string;
|
name?: string;
|
||||||
topic?: string;
|
topic?: string;
|
||||||
preset?: string;
|
preset?: string;
|
||||||
power_level_content_override?: any;
|
power_level_content_override?: any;// eslint-disable-line camelcase
|
||||||
creation_content?: any;
|
creation_content?: any;// eslint-disable-line camelcase
|
||||||
initial_state?: {type: string, state_key: string, content: any}[];
|
initial_state?: {type: string, state_key: string, content: any}[]; // eslint-disable-line camelcase
|
||||||
// TODO: Types (next line)
|
// TODO: Types (next line)
|
||||||
invite_3pid?: any[]; // eslint-disable-line camelcase
|
invite_3pid?: any[]; // eslint-disable-line camelcase
|
||||||
}
|
}
|
||||||
|
@@ -104,7 +104,8 @@ import {
|
|||||||
RoomCreateTypeField,
|
RoomCreateTypeField,
|
||||||
RoomType,
|
RoomType,
|
||||||
UNSTABLE_MSC3088_ENABLED,
|
UNSTABLE_MSC3088_ENABLED,
|
||||||
UNSTABLE_MSC3088_PURPOSE, UNSTABLE_MSC3089_TREE_SUBTYPE
|
UNSTABLE_MSC3088_PURPOSE,
|
||||||
|
UNSTABLE_MSC3089_TREE_SUBTYPE,
|
||||||
} from "./@types/event";
|
} from "./@types/event";
|
||||||
import { IImageInfo } from "./@types/partials";
|
import { IImageInfo } from "./@types/partials";
|
||||||
import { EventMapper, eventMapperFor, MapperOpts } from "./event-mapper";
|
import { EventMapper, eventMapperFor, MapperOpts } from "./event-mapper";
|
||||||
|
Reference in New Issue
Block a user