koishi-test-utils
Version:
Test utilities for Koishi
35 lines (34 loc) • 918 B
TypeScript
import { Tables, TableType, App, Database } from 'koishi-core';
declare module 'koishi-core' {
interface Database {
memory: MemoryDatabase;
}
namespace Database {
interface Statics {
'koishi-test-utils': typeof MemoryDatabase;
}
}
}
export interface MemoryConfig {
}
export interface MemoryDatabase extends Database {
}
interface TableConfig<O> {
primary?: keyof O;
}
export declare class MemoryDatabase {
app: App;
config: MemoryConfig;
$store: {
[K in TableType]?: Tables[K][];
};
memory: this;
static tables: {
[K in TableType]?: TableConfig<Tables[K]>;
};
constructor(app: App, config: MemoryConfig);
$table<K extends TableType>(table: K): any[];
$count<K extends TableType>(table: K, field?: keyof Tables[K]): number;
}
export declare function apply(app: App, config?: MemoryConfig): void;
export {};