Skip to content

Commit

Permalink
[wip] add bg-success to selected profile, fail at writing test
Browse files Browse the repository at this point in the history
  • Loading branch information
batpad committed May 31, 2024
1 parent 1984d7a commit 24e5805
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ProfileForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function Form() {
const { display_name, description, profile_options, slug } = profile;

return (
<div key={slug} className="profile-select">
<div key={slug} className={`profile-select ${selectedProfile?.slug === slug ? 'bg-success' : ''}`}>
<input
type="radio"
name="select-profile"
Expand Down
19 changes: 19 additions & 0 deletions src/ProfileForm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,22 @@ test("profile marked as default is selected by default", () => {
});
expect(nonDefaultRadio.checked).toBeFalsy();
});

// test("clicking on a profile option div selects it", async () => {
// const user = userEvent.setup();
// const { container } = render(
// <SpawnerFormProvider>
// <ProfileForm />
// </SpawnerFormProvider>,
// );
// const profileElements = container.querySelectorAll('.profile-select');
// console.log('profiles', profileElements.length);
// const firstProfile = profileElements[0];
// const lastProfile = profileElements[profileElements.length - 1];
// await user.click(firstProfile);
// console.log('first profile', firstProfile.classList);
// expect(firstProfile.classList.contains('bg-success')).toBeTruthy();
// expect(lastProfile.classList.contains('bg-success')).toBeFalsy();
// const hiddenRadio = container.querySelector('[name="profile"]');
// expect(hiddenRadio.value).toEqual("foobar");
// });
1 change: 1 addition & 0 deletions src/form.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
.profile-select {
margin-bottom: 5rem;
display: flex;
padding: 2rem;
flex-direction: row;
border-bottom: 1px solid #ccc;
}
Expand Down

0 comments on commit 24e5805

Please sign in to comment.