Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(account-settings): align classnames #3128

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {

import { useAuth } from '../../../internal';
import { View, Flex } from '../../../primitives';
import { ComponentClassName } from '../constants';
import { FormValues, BlurredFields, ValidationError } from '../types';
import { ChangePasswordProps, ValidateParams } from './types';
import DEFAULTS from './defaults';
Expand Down Expand Up @@ -177,7 +178,11 @@ function ChangePassword({
}

return (
<View as="form" className="amplify-changepassword" onSubmit={handleSubmit}>
<View
as="form"
className={ComponentClassName.ChangePassword}
onSubmit={handleSubmit}
>
<Flex direction="column">
<CurrentPassword
autoComplete="current-password"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as UIModule from '@aws-amplify/ui';
import ChangePassword from '../ChangePassword';
import { Button } from '../../../../primitives';
import { ChangePasswordComponents } from '../types';
import { ComponentClassName } from '../../constants';

const components: ChangePasswordComponents = {
CurrentPassword: (props) => (
Expand Down Expand Up @@ -56,6 +57,11 @@ describe('ChangePassword', () => {
it('renders as expected', () => {
const { container } = render(<ChangePassword />);
expect(container).toMatchSnapshot();

const changePassword = container.getElementsByClassName(
ComponentClassName.ChangePassword
);
expect(changePassword).toHaveLength(1);
});

it('calls changePassword with expected arguments', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`ChangePassword renders as expected 1`] = `
<div>
<form
class="amplify-changepassword"
class="amplify-accountsettings-changepassword"
>
<div
class="amplify-flex"
Expand Down Expand Up @@ -220,7 +220,7 @@ exports[`ChangePassword renders as expected 1`] = `
exports[`ChangePassword renders as expected with component overrides 1`] = `
<div>
<form
class="amplify-changepassword"
class="amplify-accountsettings-changepassword"
>
<div
class="amplify-flex"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { deleteUser, translate, getLogger } from '@aws-amplify/ui';

import { useAuth } from '../../../internal';
import { Flex } from '../../../primitives';
import { ComponentClassName } from '../constants';
import DEFAULTS from './defaults';
import { DeleteUserProps, DeleteUserState } from './types';

Expand Down Expand Up @@ -87,7 +88,7 @@ function DeleteUser({
}

return (
<Flex direction="column">
<Flex className={ComponentClassName.DeleteUser} direction="column">
<SubmitButton
isDisabled={state === 'CONFIRMATION'}
onClick={startConfirmation}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import React from 'react';
import {
render,
screen,
fireEvent,
waitFor,
act,
} from '@testing-library/react';
import { render, screen, fireEvent, waitFor } from '@testing-library/react';

import * as UIModule from '@aws-amplify/ui';

import { Button, Flex, Heading, Text } from '../../../../primitives';
import { ComponentClassName } from '../../constants';
import { DeleteUserComponents } from '../types';
import DeleteUser from '../DeleteUser';

Expand Down Expand Up @@ -54,6 +49,11 @@ describe('ChangePassword', () => {
it('renders as expected', () => {
const { container } = render(<DeleteUser />);
expect(container).toMatchSnapshot();

const deleteUser = container.getElementsByClassName(
ComponentClassName.DeleteUser
);
expect(deleteUser).toHaveLength(1);
});

it('calls deleteUser with expected arguments', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`ChangePassword renders as expected 1`] = `
<div>
<div
class="amplify-flex"
class="amplify-flex amplify-accountsettings-deleteuser"
style="flex-direction: column;"
>
<button
Expand All @@ -20,7 +20,7 @@ exports[`ChangePassword renders as expected 1`] = `
exports[`ChangePassword renders as expected with components overrides 1`] = `
<div>
<div
class="amplify-flex"
class="amplify-flex amplify-accountsettings-deleteuser"
style="flex-direction: column;"
>
<button
Expand Down
4 changes: 4 additions & 0 deletions packages/react/src/components/AccountSettings/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum ComponentClassName {
ChangePassword = 'amplify-accountsettings-changepassword',
DeleteUser = 'amplify-accountsettings-deleteuser',
}