You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-07 23:02:56 +03:00
Apply prettier formatting
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
import { RelationType } from "../../src";
|
||||
import { FilterComponent } from "../../src/filter-component";
|
||||
import { mkEvent } from '../test-utils/test-utils';
|
||||
import { mkEvent } from "../test-utils/test-utils";
|
||||
|
||||
describe("Filter Component", function() {
|
||||
describe("types", function() {
|
||||
it("should filter out events with other types", function() {
|
||||
const filter = new FilterComponent({ types: ['m.room.message'] });
|
||||
describe("Filter Component", function () {
|
||||
describe("types", function () {
|
||||
it("should filter out events with other types", function () {
|
||||
const filter = new FilterComponent({ types: ["m.room.message"] });
|
||||
const event = mkEvent({
|
||||
type: 'm.room.member',
|
||||
content: { },
|
||||
room: 'roomId',
|
||||
type: "m.room.member",
|
||||
content: {},
|
||||
room: "roomId",
|
||||
event: true,
|
||||
});
|
||||
|
||||
@@ -18,12 +18,12 @@ describe("Filter Component", function() {
|
||||
expect(checkResult).toBe(false);
|
||||
});
|
||||
|
||||
it("should validate events with the same type", function() {
|
||||
const filter = new FilterComponent({ types: ['m.room.message'] });
|
||||
it("should validate events with the same type", function () {
|
||||
const filter = new FilterComponent({ types: ["m.room.message"] });
|
||||
const event = mkEvent({
|
||||
type: 'm.room.message',
|
||||
content: { },
|
||||
room: 'roomId',
|
||||
type: "m.room.message",
|
||||
content: {},
|
||||
room: "roomId",
|
||||
event: true,
|
||||
});
|
||||
|
||||
@@ -32,17 +32,20 @@ describe("Filter Component", function() {
|
||||
expect(checkResult).toBe(true);
|
||||
});
|
||||
|
||||
it("should filter out events by relation participation", function() {
|
||||
const currentUserId = '@me:server.org';
|
||||
const filter = new FilterComponent({
|
||||
related_by_senders: [currentUserId],
|
||||
}, currentUserId);
|
||||
it("should filter out events by relation participation", function () {
|
||||
const currentUserId = "@me:server.org";
|
||||
const filter = new FilterComponent(
|
||||
{
|
||||
related_by_senders: [currentUserId],
|
||||
},
|
||||
currentUserId,
|
||||
);
|
||||
|
||||
const threadRootNotParticipated = mkEvent({
|
||||
type: 'm.room.message',
|
||||
type: "m.room.message",
|
||||
content: {},
|
||||
room: 'roomId',
|
||||
user: '@someone-else:server.org',
|
||||
room: "roomId",
|
||||
user: "@someone-else:server.org",
|
||||
event: true,
|
||||
unsigned: {
|
||||
"m.relations": {
|
||||
@@ -57,14 +60,17 @@ describe("Filter Component", function() {
|
||||
expect(filter.check(threadRootNotParticipated)).toBe(false);
|
||||
});
|
||||
|
||||
it("should keep events by relation participation", function() {
|
||||
const currentUserId = '@me:server.org';
|
||||
const filter = new FilterComponent({
|
||||
related_by_senders: [currentUserId],
|
||||
}, currentUserId);
|
||||
it("should keep events by relation participation", function () {
|
||||
const currentUserId = "@me:server.org";
|
||||
const filter = new FilterComponent(
|
||||
{
|
||||
related_by_senders: [currentUserId],
|
||||
},
|
||||
currentUserId,
|
||||
);
|
||||
|
||||
const threadRootParticipated = mkEvent({
|
||||
type: 'm.room.message',
|
||||
type: "m.room.message",
|
||||
content: {},
|
||||
unsigned: {
|
||||
"m.relations": {
|
||||
@@ -74,23 +80,23 @@ describe("Filter Component", function() {
|
||||
},
|
||||
},
|
||||
},
|
||||
user: '@someone-else:server.org',
|
||||
room: 'roomId',
|
||||
user: "@someone-else:server.org",
|
||||
room: "roomId",
|
||||
event: true,
|
||||
});
|
||||
|
||||
expect(filter.check(threadRootParticipated)).toBe(true);
|
||||
});
|
||||
|
||||
it("should filter out events by relation type", function() {
|
||||
it("should filter out events by relation type", function () {
|
||||
const filter = new FilterComponent({
|
||||
related_by_rel_types: ["m.thread"],
|
||||
});
|
||||
|
||||
const referenceRelationEvent = mkEvent({
|
||||
type: 'm.room.message',
|
||||
type: "m.room.message",
|
||||
content: {},
|
||||
room: 'roomId',
|
||||
room: "roomId",
|
||||
event: true,
|
||||
unsigned: {
|
||||
"m.relations": {
|
||||
@@ -102,13 +108,13 @@ describe("Filter Component", function() {
|
||||
expect(filter.check(referenceRelationEvent)).toBe(false);
|
||||
});
|
||||
|
||||
it("should keep events by relation type", function() {
|
||||
it("should keep events by relation type", function () {
|
||||
const filter = new FilterComponent({
|
||||
related_by_rel_types: ["m.thread"],
|
||||
});
|
||||
|
||||
const threadRootEvent = mkEvent({
|
||||
type: 'm.room.message',
|
||||
type: "m.room.message",
|
||||
content: {},
|
||||
unsigned: {
|
||||
"m.relations": {
|
||||
@@ -118,22 +124,22 @@ describe("Filter Component", function() {
|
||||
},
|
||||
},
|
||||
},
|
||||
room: 'roomId',
|
||||
room: "roomId",
|
||||
event: true,
|
||||
});
|
||||
|
||||
const eventWithMultipleRelations = mkEvent({
|
||||
"type": "m.room.message",
|
||||
"content": {},
|
||||
"unsigned": {
|
||||
type: "m.room.message",
|
||||
content: {},
|
||||
unsigned: {
|
||||
"m.relations": {
|
||||
"testtesttest": {},
|
||||
"m.annotation": {
|
||||
"chunk": [
|
||||
chunk: [
|
||||
{
|
||||
"type": "m.reaction",
|
||||
"key": "🤫",
|
||||
"count": 1,
|
||||
type: "m.reaction",
|
||||
key: "🤫",
|
||||
count: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -143,20 +149,20 @@ describe("Filter Component", function() {
|
||||
},
|
||||
},
|
||||
},
|
||||
"room": 'roomId',
|
||||
"event": true,
|
||||
room: "roomId",
|
||||
event: true,
|
||||
});
|
||||
|
||||
const noMatchEvent = mkEvent({
|
||||
"type": "m.room.message",
|
||||
"content": {},
|
||||
"unsigned": {
|
||||
type: "m.room.message",
|
||||
content: {},
|
||||
unsigned: {
|
||||
"m.relations": {
|
||||
"testtesttest": {},
|
||||
testtesttest: {},
|
||||
},
|
||||
},
|
||||
"room": 'roomId',
|
||||
"event": true,
|
||||
room: "roomId",
|
||||
event: true,
|
||||
});
|
||||
|
||||
expect(filter.check(threadRootEvent)).toBe(true);
|
||||
|
Reference in New Issue
Block a user