Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Half-Shot committed Nov 5, 2020
1 parent 51dfa6c commit df126c7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/clientfactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class DiscordClientFactory {
messageCacheLifetime: 5,
ws: {
intents: this.config.usePriviledgedIntents ? Intents.PRIVILEGED : Intents.NON_PRIVILEGED,
}
},
});

const waitPromise = new Promise((resolve, reject) => {
Expand All @@ -70,7 +70,7 @@ export class DiscordClientFactory {
messageCacheLifetime: 5,
ws: {
intents: Intents.NON_PRIVILEGED,
}
},
});

await client.login(token, false);
Expand Down Expand Up @@ -103,7 +103,7 @@ export class DiscordClientFactory {
messageCacheLifetime: 5,
ws: {
intents: Intents.NON_PRIVILEGED,
}
},
});

const jsLog = new Log("discord.js-ppt");
Expand Down
8 changes: 3 additions & 5 deletions src/db/sqlite3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,18 @@ limitations under the License.
*/

import * as BetterSQLite3 from "better-sqlite3";
import { Database } from "better-sqlite3";
import { Log } from "../log";
import { IDatabaseConnector, ISqlCommandParameters, ISqlRow } from "./connector";
const log = new Log("SQLite3");

export class SQLite3 implements IDatabaseConnector {
private db: Database;
private db: BetterSQLite3.Database;
constructor(private filename: string) {

}

public async Open() {
log.info(`Opening ${this.filename}`);

this.db = new BetterSQLite3(this.filename);
}

Expand All @@ -44,7 +42,7 @@ export class SQLite3 implements IDatabaseConnector {

public async Run(sql: string, parameters?: ISqlCommandParameters): Promise<void> {
log.silly("Run:", sql);
await this.db.prepare(sql).run(parameters || []);
this.db.prepare(sql).run(parameters || []);
}

public async Close(): Promise<void> {
Expand All @@ -53,6 +51,6 @@ export class SQLite3 implements IDatabaseConnector {

public async Exec(sql: string): Promise<void> {
log.silly("Exec:", sql);
await this.db.exec(sql);
this.db.exec(sql);
}
}
11 changes: 11 additions & 0 deletions test/mocks/discordclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ export class MockDiscordClient {
this.testCallbacks.set(event, callback);
}

public once(event: string, callback: (...data: any[]) => void) {
this.testCallbacks.set(event, () => {
this.testCallbacks.delete(event);
callback();
});
}


public async emit(event: string, ...data: any[]) {
return await this.testCallbacks.get(event)!.apply(this, data);
}
Expand All @@ -67,6 +75,9 @@ export class MockDiscordClient {
if (this.testCallbacks.has("ready")) {
this.testCallbacks.get("ready")!();
}
if (this.testCallbacks.has("shardReady")) {
this.testCallbacks.get("shardReady")!();
}
return;
}

Expand Down

0 comments on commit df126c7

Please sign in to comment.