scriptable-testlab
Version:
A lightweight, efficient tool designed to manage and update scripts for Scriptable.
62 lines (54 loc) • 1.07 kB
text/typescript
import {AbsModule} from 'scriptable-abstract';
interface ModuleState {
filename: string;
exports: Record<string, unknown>;
}
/**
* Mock implementation of Scriptable's module global variable
* Provides functionality for module-related operations
*
* @implements Module
*/
export class MockModule extends AbsModule<ModuleState> {
static get instance(): MockModule {
return super.instance as MockModule;
}
constructor() {
super({
filename: 'mock-module.js',
exports: {},
});
}
/**
* @inheritdoc
*/
get filename(): string {
return this.state.filename;
}
/**
* @inheritdoc
*/
get exports(): Record<string, unknown> {
return this.state.exports;
}
/**
* @additional
* Set the module filename
*/
setFilename(filename: string): void {
this.setState({
...this.state,
filename,
});
}
/**
* @additional
* Set module exports
*/
setExports(exports: Record<string, unknown>): void {
this.setState({
...this.state,
exports,
});
}
}