chore: Standardize code, comments and docs on US-English spelling (#2707)
This commit is contained in:
@@ -92,7 +92,7 @@ export const tabUntil = async (
|
||||
|
||||
/**
|
||||
* Click an element with a real pointer, which is the only kind that carries the
|
||||
* browser's own behaviour: the press moves focus, and an element that stops the
|
||||
* browser's own behavior: the press moves focus, and an element that stops the
|
||||
* press doing so leaves it where it was.
|
||||
*/
|
||||
export const clickElement = async (element: Element): Promise<void> =>
|
||||
|
||||
@@ -92,12 +92,12 @@ const createRegistryEntry = (entityID: string, overrides?: Partial<Entity>): Ent
|
||||
* A driveable stand-in for the `hass` object the card is handed by Home
|
||||
* Assistant.
|
||||
*
|
||||
* Home Assistant updates immutably, and that is the behaviour reproduced here:
|
||||
* a change hands consumers a new top-level object and a new `states` map
|
||||
* holding a new state object for the entity that changed, while every other
|
||||
* entity keeps the object it already had. Anything the card can observe about
|
||||
* a real `hass` it must be able to observe about this one, so a divergence here
|
||||
* is a bug in the fake rather than a shortcut worth taking.
|
||||
* Home Assistant updates immutably, and that is the behavior reproduced here: a
|
||||
* change hands consumers a new top-level object and a new `states` map holding
|
||||
* a new state object for the entity that changed, while every other entity
|
||||
* keeps the object it already had. Anything the card can observe about a real
|
||||
* `hass` it must be able to observe about this one, so a divergence here is a
|
||||
* bug in the fake rather than a shortcut worth taking.
|
||||
*/
|
||||
export class FakeHASS {
|
||||
private _hass: HomeAssistant;
|
||||
|
||||
@@ -40,8 +40,8 @@ class HAPlayerStandIn extends LitElement {
|
||||
}
|
||||
|
||||
/**
|
||||
* A stand-in that renders its children and nothing else. Behaviour is added
|
||||
* only for elements the card is observed to depend on.
|
||||
* A stand-in that renders its children and nothing else. Behavior is added only
|
||||
* for elements the card is observed to depend on.
|
||||
*/
|
||||
class HAElementStub extends LitElement {
|
||||
static styles = css`
|
||||
|
||||
@@ -158,11 +158,11 @@ interface EventEntry {
|
||||
target: EventTarget | null;
|
||||
}
|
||||
|
||||
interface LabelledElement extends Element {
|
||||
interface LabeledElement extends Element {
|
||||
label?: string;
|
||||
}
|
||||
|
||||
const hasLabel = (element: Element): element is LabelledElement => 'label' in element;
|
||||
const hasLabel = (element: Element): element is LabeledElement => 'label' in element;
|
||||
|
||||
/**
|
||||
* What a control calls itself to the user. The card titles the controls it
|
||||
|
||||
@@ -36,7 +36,7 @@ const HOME_ASSISTANT_THEME = `
|
||||
color: var(--primary-text-color);
|
||||
}
|
||||
|
||||
/* A dashboard sits the card on the background colour with room around it. */
|
||||
/* A dashboard sits the card on the background color with room around it. */
|
||||
body {
|
||||
background: var(--primary-background-color);
|
||||
margin: 0;
|
||||
|
||||
@@ -87,13 +87,13 @@ export const getTestMediaRequestCount = (url: string): number => {
|
||||
/**
|
||||
* Serves a fixture at `/test-media/<file>`, behaving as the query asks:
|
||||
*
|
||||
* token Which counter the request belongs to, so that a test's
|
||||
* behaviour does not depend on what ran before it.
|
||||
* responses The status to answer each request with, in order: `200` serves
|
||||
* the file and anything else is sent as an empty error.
|
||||
* repeat What to do once the `responses` list is exhausted: answer every
|
||||
* request after it as the last one was, or never answer again
|
||||
* (i.e. camera going quiet).
|
||||
* token Which counter the request belongs to, so that a test's behavior
|
||||
* does not depend on what ran before it. responses The status to
|
||||
* answer each request with, in order: `200` serves the file and
|
||||
* anything else is sent as an empty error. repeat What to do
|
||||
* once the `responses` list is exhausted: answer every request
|
||||
* after it as the last one was, or never answer again (i.e. camera
|
||||
* going quiet).
|
||||
*
|
||||
* Answered from within the page rather than by a server, because a request the
|
||||
* page is still waiting on holds one of the handful of connections a browser
|
||||
|
||||
@@ -1373,8 +1373,8 @@ describe('answer', () => {
|
||||
|
||||
expect(getRingtone().stop).toHaveBeenCalled();
|
||||
|
||||
// Timer was armed and should now be cancelled: advancing past the
|
||||
// timeout must not end the (now-answered) call.
|
||||
// Timer was armed and should now be canceled: advancing past the timeout
|
||||
// must not end the (now-answered) call.
|
||||
vi.advanceTimersByTime(60_000);
|
||||
expect(manager.isActive()).toBe(true);
|
||||
} finally {
|
||||
|
||||
@@ -12,8 +12,8 @@ interface AudioMocks {
|
||||
}
|
||||
|
||||
// Uses real jsdom HTMLAudioElement instances and only stubs the parts jsdom
|
||||
// can't fulfil (`play()` / `pause()` -- no audio backend). Tests then exercise
|
||||
// observable behaviour: registered listeners fire via `dispatchEvent`, property
|
||||
// can't fulfill (`play()` / `pause()` -- no audio backend). Tests then exercise
|
||||
// observable behavior: registered listeners fire via `dispatchEvent`, property
|
||||
// writes round-trip on the element, etc.
|
||||
//
|
||||
// Called once at module load. The `beforeEach`/`afterEach` calls inside this
|
||||
|
||||
@@ -538,7 +538,8 @@ describe('CameraTriggersManager', () => {
|
||||
vi.runOnlyPendingTimers();
|
||||
await flushPromises();
|
||||
|
||||
// Should still be triggered because the second 'new' event should have cancelled the first timer.
|
||||
// Should still be triggered because the second 'new' event should have
|
||||
// canceled the first timer.
|
||||
expect(manager.isTriggered()).toBeTruthy();
|
||||
expect(api.getViewManager().setViewDefaultWithNewQuery).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -245,7 +245,7 @@ describe('SessionManager', () => {
|
||||
});
|
||||
});
|
||||
|
||||
// The user-facing behaviour the machine exists for, driven through the real
|
||||
// The user-facing behavior the machine exists for, driven through the real
|
||||
// schema, trigger factory and evaluator rather than hand-written state.
|
||||
describe('should drive the initialized trigger', () => {
|
||||
it('should fire once per session and not when a session ends', () => {
|
||||
|
||||
@@ -873,7 +873,7 @@ describe('IssueManager', () => {
|
||||
|
||||
// The attempt is now in flight: the problem is still unresolved
|
||||
// (needsRetry) but cannot be retried right now (canRetryNow). The running
|
||||
// timer is cancelled and no further attempt fires, however long we wait.
|
||||
// timer is canceled and no further attempt fires, however long we wait.
|
||||
canRetryNow.mockReturnValue(false);
|
||||
manager.evaluate();
|
||||
vi.advanceTimersByTime(RETRY_EXPONENTIAL_MAX_SECONDS * 1000);
|
||||
|
||||
@@ -488,7 +488,7 @@ describe('MediaUnavailableIssue', () => {
|
||||
|
||||
await card.events.waitForFirst('advanced-camera-card:issue:trigger');
|
||||
|
||||
// The status bar only summarises. Everything a user can do about the
|
||||
// The status bar only summarizes. Everything a user can do about the
|
||||
// failure is behind it, which is the point of the issue report being
|
||||
// clickable.
|
||||
await card.clickControl(MEDIA_ISSUE_TITLE);
|
||||
|
||||
@@ -7,9 +7,9 @@ import {
|
||||
createStillImageCardConfig,
|
||||
} from '../browser/test-utils';
|
||||
|
||||
// A colour the dark theme sets and the card carries no other way. Reading it
|
||||
// back proves the stylesheet reached the card rather than merely compiling.
|
||||
// See src/scss/themes/dark.scss .
|
||||
// A color the dark theme sets and the card carries no other way. Reading it
|
||||
// back proves the stylesheet reached the card rather than merely compiling. See
|
||||
// src/scss/themes/dark.scss .
|
||||
const DARK_PRIMARY_BACKGROUND = '#111111';
|
||||
|
||||
const mountThemed = async (themes: ThemeName[]) =>
|
||||
|
||||
@@ -118,7 +118,7 @@ describe('computeFormLabel', () => {
|
||||
});
|
||||
|
||||
it('should return an empty label for a grid', () => {
|
||||
// The fields a grid lays out are labelled individually; the grid itself
|
||||
// The fields a grid lays out are labeled individually; the grid itself
|
||||
// shows nothing.
|
||||
expect(computeFormLabel(createForm([]), { type: 'grid', schema: [] })).toBe('');
|
||||
});
|
||||
|
||||
@@ -379,7 +379,7 @@ describe('NumericStateTrigger', () => {
|
||||
setHass(stateManager, { [SENSOR]: { state: '25' } });
|
||||
vi.advanceTimersByTime(3000);
|
||||
|
||||
// Leaves the range before the hold elapses: cancelled.
|
||||
// Leaves the range before the hold elapses: canceled.
|
||||
setHass(stateManager, { [SENSOR]: { state: '10' } });
|
||||
vi.advanceTimersByTime(5000);
|
||||
expect(callback).not.toHaveBeenCalled();
|
||||
|
||||
@@ -14,7 +14,7 @@ describe('preprocessToArray', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should normalise a single item to a list', () => {
|
||||
it('should normalize a single item to a list', () => {
|
||||
expect(schema.parse({ items: { name: 'office' } })).toEqual({
|
||||
items: [{ name: 'office' }],
|
||||
});
|
||||
|
||||
@@ -1389,7 +1389,7 @@ describe('conditions should accept Home Assistant composite shorthand', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should normalise a single shorthand condition to a list', () => {
|
||||
it('should normalize a single shorthand condition to a list', () => {
|
||||
expect(
|
||||
conditionSchema.parse({ or: { condition: 'fullscreen', fullscreen: true } }),
|
||||
).toMatchObject({
|
||||
@@ -1760,7 +1760,7 @@ describe('should lazy evaluate schemas', () => {
|
||||
).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should normalise single if/then/else items to lists', () => {
|
||||
it('should normalize single if/then/else items to lists', () => {
|
||||
const result = actionConfigSchema.parse({
|
||||
if: { condition: 'state', entity_id: 'light.office', state: 'on' },
|
||||
then: {
|
||||
@@ -1912,7 +1912,7 @@ describe('automations should require actions', () => {
|
||||
});
|
||||
|
||||
describe('automations should accept Home Assistant input shorthands', () => {
|
||||
it('should normalise singular keys and single items to lists', () => {
|
||||
it('should normalize singular keys and single items to lists', () => {
|
||||
const result = automationsSchema.parse([
|
||||
{
|
||||
trigger: { trigger: 'state', entity_id: 'binary_sensor.door', to: 'on' },
|
||||
|
||||
Vendored
+1
-1
@@ -227,7 +227,7 @@ describe('the built card', () => {
|
||||
// only through the accessors `@property` installs. Were the decorator
|
||||
// output wrong, writes would land on plain instance fields and none of this
|
||||
// would work. This verifies the build's treatment of decorators rather than
|
||||
// the card's behaviour per se (already well covered in other tests).
|
||||
// the card's behavior per se (already well covered in other tests).
|
||||
await mounted.events.waitForFirst('advanced-camera-card:media:loaded');
|
||||
|
||||
expect(isLiveMediaShowing(mounted.card)).toBe(true);
|
||||
|
||||
Reference in New Issue
Block a user