mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 19:45:05 +01:00
fix tests
This commit is contained in:
parent
299294daff
commit
575f3fa966
@ -114,39 +114,45 @@ export function tests() {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
"redact somebody else event with power level event": assert => {
|
"redact somebody else event with power level event": assert => {
|
||||||
const pl1 = new PowerLevels({powerLevelEvent: redactPowerLevelEvent, ownUserId: alice});
|
const pl1 = new PowerLevels({powerLevelEvent: redactPowerLevelEvent, ownUserId: alice, membership: "join"});
|
||||||
assert.equal(pl1.canRedact, true);
|
assert.equal(pl1.canRedact, true);
|
||||||
const pl2 = new PowerLevels({powerLevelEvent: redactPowerLevelEvent, ownUserId: bob});
|
const pl2 = new PowerLevels({powerLevelEvent: redactPowerLevelEvent, ownUserId: bob, membership: "join"});
|
||||||
assert.equal(pl2.canRedact, false);
|
assert.equal(pl2.canRedact, false);
|
||||||
},
|
},
|
||||||
"redact somebody else event with create event": assert => {
|
"redact somebody else event with create event": assert => {
|
||||||
const pl1 = new PowerLevels({createEvent, ownUserId: alice});
|
const pl1 = new PowerLevels({createEvent, ownUserId: alice, membership: "join"});
|
||||||
assert.equal(pl1.canRedact, true);
|
assert.equal(pl1.canRedact, true);
|
||||||
const pl2 = new PowerLevels({createEvent, ownUserId: bob});
|
const pl2 = new PowerLevels({createEvent, ownUserId: bob, membership: "join"});
|
||||||
assert.equal(pl2.canRedact, false);
|
assert.equal(pl2.canRedact, false);
|
||||||
},
|
},
|
||||||
"redact own event": assert => {
|
"redact own event": assert => {
|
||||||
const pl = new PowerLevels({ownUserId: alice});
|
const pl = new PowerLevels({ownUserId: alice, membership: "join"});
|
||||||
assert.equal(pl.canRedactFromSender(alice), true);
|
assert.equal(pl.canRedactFromSender(alice), true);
|
||||||
assert.equal(pl.canRedactFromSender(bob), false);
|
assert.equal(pl.canRedactFromSender(bob), false);
|
||||||
},
|
},
|
||||||
"can send event without power levels": assert => {
|
"can send event without power levels": assert => {
|
||||||
const pl = new PowerLevels({createEvent, ownUserId: charly});
|
const pl = new PowerLevels({createEvent, ownUserId: charly, membership: "join"});
|
||||||
assert.equal(pl.canSendType("m.room.message"), true);
|
assert.equal(pl.canSendType("m.room.message"), true);
|
||||||
},
|
},
|
||||||
"can't send any event below events_default": assert => {
|
"can't send any event below events_default": assert => {
|
||||||
const pl = new PowerLevels({powerLevelEvent: eventsPowerLevelEvent, ownUserId: charly});
|
const pl = new PowerLevels({powerLevelEvent: eventsPowerLevelEvent, ownUserId: charly, membership: "join"});
|
||||||
assert.equal(pl.canSendType("m.foo"), false);
|
assert.equal(pl.canSendType("m.foo"), false);
|
||||||
},
|
},
|
||||||
"can't send event below events[type]": assert => {
|
"can't send event below events[type]": assert => {
|
||||||
const pl = new PowerLevels({powerLevelEvent: eventsPowerLevelEvent, ownUserId: bob});
|
const pl = new PowerLevels({powerLevelEvent: eventsPowerLevelEvent, ownUserId: bob, membership: "join"});
|
||||||
assert.equal(pl.canSendType("m.foo"), true);
|
assert.equal(pl.canSendType("m.foo"), true);
|
||||||
assert.equal(pl.canSendType("m.room.message"), false);
|
assert.equal(pl.canSendType("m.room.message"), false);
|
||||||
},
|
},
|
||||||
"can send event above or at events[type]": assert => {
|
"can send event above or at events[type]": assert => {
|
||||||
const pl = new PowerLevels({powerLevelEvent: eventsPowerLevelEvent, ownUserId: alice});
|
const pl = new PowerLevels({powerLevelEvent: eventsPowerLevelEvent, ownUserId: alice, membership: "join"});
|
||||||
assert.equal(pl.canSendType("m.room.message"), true);
|
assert.equal(pl.canSendType("m.room.message"), true);
|
||||||
assert.equal(pl.canSendType("m.room.topic"), true);
|
assert.equal(pl.canSendType("m.room.topic"), true);
|
||||||
},
|
},
|
||||||
|
"can't redact or send in non-joined room'": assert => {
|
||||||
|
const pl = new PowerLevels({createEvent, ownUserId: alice, membership: "leave"});
|
||||||
|
assert.equal(pl.canRedact, false);
|
||||||
|
assert.equal(pl.canRedactFromSender(alice), false);
|
||||||
|
assert.equal(pl.canSendType("m.room.message"), false);
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user