chore: migrate project to Bun testing framework and update configuration

- Replace Jest with Bun's native testing framework
- Update test configuration and utilities to support Bun test environment
- Add mock implementations for SSE and security testing
- Refactor test setup to use Bun's testing utilities
- Update package dependencies and scripts to align with Bun testing
- Enhance type definitions for Bun test mocking
This commit is contained in:
jango-blockchained
2025-02-03 22:19:43 +01:00
parent b7856e9d05
commit a53cec7b28
12 changed files with 403 additions and 175 deletions

View File

@@ -0,0 +1,77 @@
import { mock } from 'bun:test';
export const LIB_HASS = {
configuration: {
name: 'Home Assistant',
version: '2024.2.0',
location_name: 'Home',
time_zone: 'UTC',
components: ['automation', 'script', 'light', 'switch'],
unit_system: {
temperature: '°C',
length: 'm',
mass: 'kg',
pressure: 'hPa',
volume: 'L'
}
},
services: {
light: {
turn_on: mock(() => Promise.resolve()),
turn_off: mock(() => Promise.resolve()),
toggle: mock(() => Promise.resolve())
},
switch: {
turn_on: mock(() => Promise.resolve()),
turn_off: mock(() => Promise.resolve()),
toggle: mock(() => Promise.resolve())
},
automation: {
trigger: mock(() => Promise.resolve()),
turn_on: mock(() => Promise.resolve()),
turn_off: mock(() => Promise.resolve())
},
script: {
turn_on: mock(() => Promise.resolve()),
turn_off: mock(() => Promise.resolve()),
toggle: mock(() => Promise.resolve())
}
},
states: {
light: {
'light.living_room': {
state: 'on',
attributes: {
brightness: 255,
color_temp: 300,
friendly_name: 'Living Room Light'
}
},
'light.bedroom': {
state: 'off',
attributes: {
friendly_name: 'Bedroom Light'
}
}
},
switch: {
'switch.tv': {
state: 'off',
attributes: {
friendly_name: 'TV'
}
}
}
},
events: {
subscribe: mock(() => Promise.resolve()),
unsubscribe: mock(() => Promise.resolve()),
fire: mock(() => Promise.resolve())
},
connection: {
subscribeEvents: mock(() => Promise.resolve()),
subscribeMessage: mock(() => Promise.resolve()),
sendMessage: mock(() => Promise.resolve()),
close: mock(() => Promise.resolve())
}
};