Skip to content

Commit

Permalink
Merge branch 'account-settings/main' into account-settings/override-c…
Browse files Browse the repository at this point in the history
…leanup
  • Loading branch information
wlee221 committed Dec 2, 2022
2 parents 59dae77 + ecb2b3e commit cf95e71
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 6 deletions.
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 @@ -185,7 +186,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">
<DeleteButton
isDisabled={state === 'CONFIRMATION'}
onClick={startConfirmation}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ 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 @@ -58,6 +59,11 @@ describe('DeleteUser', () => {
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[`DeleteUser 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[`DeleteUser renders as expected 1`] = `
exports[`DeleteUser 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',
}

0 comments on commit cf95e71

Please sign in to comment.