You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-11 20:22:36 +03:00
dont show all 20 send messages
support muting a logger and chaining calls
This commit is contained in:
@@ -111,8 +111,11 @@ async function aLazyLoadingTest(alice, bob, charlies) {
|
||||
await bob.delay(500);
|
||||
await charlies.join(alias);
|
||||
const messageRange = range(1, 20);
|
||||
bob.log.step("sends 20 messages").mute();
|
||||
for(let i = 20; i >= 1; --i) {
|
||||
await sendMessage(bob, `I will only say this ${i} time(s)!`);
|
||||
}
|
||||
bob.log.unmute().done();
|
||||
await join(alice, room);
|
||||
|
||||
}
|
||||
|
||||
@@ -35,26 +35,47 @@ class Logger {
|
||||
constructor(username) {
|
||||
this.indent = 0;
|
||||
this.username = username;
|
||||
this.muted = false;
|
||||
}
|
||||
|
||||
startGroup(description) {
|
||||
if (!this.muted) {
|
||||
const indent = " ".repeat(this.indent * 2);
|
||||
console.log(`${indent} * ${this.username} ${description}:`);
|
||||
}
|
||||
this.indent += 1;
|
||||
return this;
|
||||
}
|
||||
|
||||
endGroup() {
|
||||
this.indent -= 1;
|
||||
return this;
|
||||
}
|
||||
|
||||
step(description) {
|
||||
if (!this.muted) {
|
||||
const indent = " ".repeat(this.indent * 2);
|
||||
process.stdout.write(`${indent} * ${this.username} ${description} ... `);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
done(status = "done") {
|
||||
if (!this.muted) {
|
||||
process.stdout.write(status + "\n");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
mute() {
|
||||
this.muted = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
unmute() {
|
||||
this.muted = false;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = class RiotSession {
|
||||
|
||||
Reference in New Issue
Block a user