mirror of
https://github.com/matrix-org/mjolnir.git
synced 2024-10-01 01:36:06 -04:00
splice returns removed items, not a new list with items removed
This commit is contained in:
parent
d364d9879a
commit
8b23f93b71
@ -87,8 +87,7 @@ export class StringListProtectionSetting extends AbstractProtectionListSetting<s
|
||||
return [...this.value, data];
|
||||
}
|
||||
removeValue(data: string): string[] {
|
||||
const index = this.value.indexOf(data);
|
||||
return this.value.splice(index, index + 1);
|
||||
return this.value.filter(i => i !== data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -133,20 +133,18 @@ describe("Test: Protection settings", function() {
|
||||
};
|
||||
|
||||
|
||||
let reply = new Promise((resolve, reject) => {
|
||||
let i = 0;
|
||||
let reply = () => new Promise((resolve, reject) => {
|
||||
client.on('room.message', noticeListener(this.mjolnir.managementRoomId, (event) => {
|
||||
if (event.content.body.includes("Changed oXzT0E.test ")) {
|
||||
if (++i == 2) {
|
||||
resolve(event);
|
||||
}
|
||||
}
|
||||
}))
|
||||
});
|
||||
|
||||
await client.sendMessage(this.mjolnir.managementRoomId, {msgtype: "m.text", body: "!mjolnir config add oXzT0E.test asd"})
|
||||
await reply();
|
||||
await client.sendMessage(this.mjolnir.managementRoomId, {msgtype: "m.text", body: "!mjolnir config remove oXzT0E.test asd"})
|
||||
await reply
|
||||
await reply();
|
||||
|
||||
assert.deepEqual(await this.mjolnir.getProtectionSettings("oXzT0E"), { "test": [] });
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user