Skip to content

Commit

Permalink
Run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
mahoneycm committed Oct 21, 2024
1 parent f3f6b9e commit aed6a6e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/components/usa-text-input/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import styles from "./usa-text-input.css.js";
export class UsaTextInput extends LitElement {
static styles = [styles];
static properties = {
state: { type: String, reflect: true }
state: { type: String, reflect: true },
};

connectedCallback() {
Expand Down
6 changes: 3 additions & 3 deletions src/components/usa-text-input/text-input.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ export default {
control: { type: "radio" },
options: ["Default", "success", "error", "disabled"],
table: {
defaultValue: { summary: "Default" }
}
defaultValue: { summary: "Default" },
},
},
},
args: {
state: "Default"
state: "Default",
},
render: ({ state }) => html`
<usa-text-input state=${state == "Default" ? nothing : state} test>
Expand Down
6 changes: 4 additions & 2 deletions src/components/usa-text-input/usa-text-input.css.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ export default css`
--theme-input-line-height: 1.3;
--theme-input-max-width: 30rem;
--theme-input-state-border-width: var(--usa-system-unit-05);
--theme-input-state-border-negative-margin: calc(var(--usa-system-unit-1) - vcar(--theme-input-state-border-width));
--theme-input-state-border-negative-margin: calc(
var(--usa-system-unit-1) - vcar(--theme-input-state-border-width)
);
.usa-input {
box-sizing: border-box;
Expand Down Expand Up @@ -85,7 +87,7 @@ export default css`
.usa-label--error {
font-weight: 700;
margin-top: 0
margin-top: 0;
}
}
`;
30 changes: 14 additions & 16 deletions src/components/usa-text-input/usa-text-input.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@ import { beforeEach, describe, expect, it } from "vitest";
import "./index.js";

function getInsideInput() {
return document.body
.querySelector("usa-text-input")
.shadowRoot;
return document.body.querySelector("usa-text-input").shadowRoot;
}

function getLabelElement() {
return getInsideInput().querySelector("label");
}

function getLabelContext() {
return getLabelElement().getAttribute("for")
return getLabelElement().getAttribute("for");
}

function getInputElement() {
Expand All @@ -27,17 +25,17 @@ describe("usa-text-input component", async () => {
<label for="input-type-text">Text input label</label>
<input id="input-type-text" name="input-type-text">
</usa-text-input>
`
`;
});

it("Should show props", () => {
expect(getInputElement().getAttribute("id")).toContain("input-type-text");
});

it("Should have an associated label", () => {
expect(getInputElement().getAttribute("id")).toMatch(getLabelContext());
});
})
});

describe("usa-text-input error state", async () => {
beforeEach(async () => {
Expand All @@ -46,14 +44,14 @@ describe("usa-text-input error state", async () => {
<label for="input-type-text">Text input label</label>
<input id="input-type-text" name="input-type-text">
</usa-text-input>
`
`;
});

it("Should add error classes to elements", () => {
expect(getLabelElement().classList.contains("usa-label--error"));
expect(getInputElement().classList.contains("usa-input--error"));
})
})
});
});

describe("usa-text-input success state", async () => {
beforeEach(async () => {
Expand All @@ -62,13 +60,13 @@ describe("usa-text-input success state", async () => {
<label for="input-type-text">Text input label</label>
<input id="input-type-text" name="input-type-text">
</usa-text-input>
`
`;
});

it("Should add success classes to elements", () => {
expect(getInputElement().classList.contains("usa-input--success"));
})
})
});
});

describe("usa-text-input disabled state", async () => {
beforeEach(async () => {
Expand All @@ -77,10 +75,10 @@ describe("usa-text-input disabled state", async () => {
<label for="input-type-text">Text input label</label>
<input id="input-type-text" name="input-type-text">
</usa-text-input>
`
`;
});

it("Should add disabled classes to elements", () => {
expect(getInputElement().hasAttribute("disabled"));
})
})
});
});

0 comments on commit aed6a6e

Please sign in to comment.