scriptable-testlab
Version:
A lightweight, efficient tool designed to manage and update scripts for Scriptable.
72 lines (56 loc) • 1.52 kB
text/typescript
import {AbsCalendar} from 'scriptable-abstract';
import {MockColor} from '../ui/color';
interface CalendarState {
identifier: string;
title: string;
isSubscribed: boolean;
allowsContentModifications: boolean;
color: Color;
}
const DEFAULT_STATE: CalendarState = {
identifier: '',
title: '',
isSubscribed: false,
allowsContentModifications: true,
color: new MockColor('#000000'),
};
export class MockCalendar extends AbsCalendar<CalendarState> {
constructor() {
super(DEFAULT_STATE);
}
get identifier(): string {
return this.state.identifier;
}
get title(): string {
return this.state.title;
}
get isSubscribed(): boolean {
return this.state.isSubscribed;
}
get allowsContentModifications(): boolean {
return this.state.allowsContentModifications;
}
get color(): Color {
return this.state.color;
}
static async forEvents(): Promise<Calendar[]> {
return [new MockCalendar() as unknown as Calendar];
}
static async forReminders(): Promise<Calendar[]> {
return [new MockCalendar() as unknown as Calendar];
}
static async default(): Promise<Calendar> {
return new MockCalendar() as unknown as Calendar;
}
static async findOrCreate(title: string): Promise<Calendar> {
const calendar = new MockCalendar();
calendar.setState({title});
return calendar as unknown as Calendar;
}
async save(): Promise<void> {
// Mock implementation
}
async remove(): Promise<void> {
// Mock implementation
}
}