Enhance Jest configuration and testing infrastructure

- Updated Jest configuration to support ESM and improve test coverage
- Added comprehensive test files for helpers, index, context, and HASS integration
- Configured coverage reporting and added new test scripts
- Updated Jest resolver to handle module resolution for chalk and related packages
- Introduced new test setup files for mocking and environment configuration
This commit is contained in:
jango-blockchained
2025-01-30 09:04:07 +01:00
parent f908d83cbf
commit d7e5fcf764
15 changed files with 1077 additions and 282 deletions

81
src/types/hass.d.ts vendored Normal file
View File

@@ -0,0 +1,81 @@
declare namespace HomeAssistant {
interface Entity {
entity_id: string;
state: string;
attributes: Record<string, any>;
last_changed: string;
last_updated: string;
context: {
id: string;
parent_id?: string;
user_id?: string;
};
}
interface Service {
domain: string;
service: string;
target?: {
entity_id?: string | string[];
device_id?: string | string[];
area_id?: string | string[];
};
service_data?: Record<string, any>;
}
interface WebsocketMessage {
type: string;
id?: number;
[key: string]: any;
}
interface AuthMessage extends WebsocketMessage {
type: 'auth';
access_token: string;
}
interface SubscribeEventsMessage extends WebsocketMessage {
type: 'subscribe_events';
event_type?: string;
}
interface StateChangedEvent {
event_type: 'state_changed';
data: {
entity_id: string;
new_state: Entity | null;
old_state: Entity | null;
};
origin: string;
time_fired: string;
context: {
id: string;
parent_id?: string;
user_id?: string;
};
}
interface Config {
latitude: number;
longitude: number;
elevation: number;
unit_system: {
length: string;
mass: string;
temperature: string;
volume: string;
};
location_name: string;
time_zone: string;
components: string[];
version: string;
}
interface ApiError {
code: string;
message: string;
details?: Record<string, any>;
}
}
export = HomeAssistant;