test: Split test utilities to improve test times (#2622)
This commit is contained in:
@@ -8,6 +8,10 @@ import { updateElementStyleFromMediaLayoutConfig } from '../utils/media-layout';
|
||||
|
||||
const ROTATED_ATTRIBUTE = 'rotated';
|
||||
|
||||
// Resizes arrive in bursts as the browser settles the layout, so only the last
|
||||
// one in a burst is acted upon.
|
||||
export const RESIZE_DEBOUNCE_SECONDS = 0.1;
|
||||
|
||||
interface MediaDimensions {
|
||||
width: number;
|
||||
height: number;
|
||||
@@ -32,7 +36,9 @@ export class MediaDimensionsContainerController implements ReactiveController {
|
||||
private _innerContainer: HTMLElement | null = null;
|
||||
private _outerContainer: HTMLElement | null = null;
|
||||
|
||||
public resize = debounce(this._resize.bind(this), 100, { trailing: true });
|
||||
public resize = debounce(this._resize.bind(this), RESIZE_DEBOUNCE_SECONDS * 1000, {
|
||||
trailing: true,
|
||||
});
|
||||
private _resizeObserver = new ResizeObserver(this.resize);
|
||||
|
||||
private _mediaDimensions: MediaDimensions | null = null;
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { debounce, isEqual } from 'lodash-es';
|
||||
|
||||
// Balancing act: Debounce to avoid excessive calls to setHeight, when new media
|
||||
// is loading the player may be a much smaller height momentarily.
|
||||
export const SET_HEIGHT_DEBOUNCE_SECONDS = 0.3;
|
||||
|
||||
export class MediaHeightController {
|
||||
private _host: HTMLElement;
|
||||
private _selector: string;
|
||||
@@ -13,9 +17,7 @@ export class MediaHeightController {
|
||||
|
||||
private _debouncedSetHeight = debounce(
|
||||
() => this._setHeight(),
|
||||
// Balancing act: Debounce to avoid excessive calls to setHeight, when new
|
||||
// media is loading the player may be a much smaller height momentarily.
|
||||
300,
|
||||
SET_HEIGHT_DEBOUNCE_SECONDS * 1000,
|
||||
{
|
||||
trailing: true,
|
||||
leading: false,
|
||||
|
||||
@@ -25,9 +25,6 @@ export async function homeAssistantSignPath(
|
||||
signedPathSchema,
|
||||
request,
|
||||
);
|
||||
if (!response) {
|
||||
return null;
|
||||
}
|
||||
return hass.hassUrl(response.path);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user