Skip to content

Commit

Permalink
Merge pull request #2205 from anuradha9712/feat-sara-component
Browse files Browse the repository at this point in the history
feat(sara): add new sara component
  • Loading branch information
innosatyam authored Jun 4, 2024
2 parents cfcdd46 + 848ee75 commit abcada2
Show file tree
Hide file tree
Showing 10 changed files with 633 additions and 0 deletions.
18 changes: 18 additions & 0 deletions core/ai-components/Sara/__stories__/customSize.story.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import { Sara } from '@/index';

export const CustomSize = () => {
return <Sara size={100} />;
};

export default {
title: 'Components/AI/Sara/Custom Size',
component: Sara,
parameters: {
docs: {
docPage: {
title: 'Sara',
},
},
},
};
18 changes: 18 additions & 0 deletions core/ai-components/Sara/__stories__/index.story.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import { Sara } from '@/index';

export const All = () => {
return <Sara />;
};

export default {
title: 'Components/AI/Sara/All',
component: Sara,
parameters: {
docs: {
docPage: {
title: 'Sara',
},
},
},
};
41 changes: 41 additions & 0 deletions core/ai-components/Sara/__stories__/size.story.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React from 'react';
import { Sara, Text } from '@/index';

export const Sizes = () => {
return (
<div>
<div className="d-flex justify-content-between align-items-center w-75">
<div className="d-flex flex-column align-items-center text-align-center w-100">
<Sara />
<Text appearance="subtle" className="mt-6">
32
</Text>
</div>
<div className="d-flex flex-column align-items-center text-align-center w-100">
<Sara size={48} />
<Text appearance="subtle" className="mt-6">
48
</Text>
</div>
<div className="d-flex flex-column align-items-center text-align-center w-100">
<Sara size={64} />
<Text appearance="subtle" className="mt-6">
64
</Text>
</div>
</div>
</div>
);
};

export default {
title: 'Components/AI/Sara/Sizes',
component: Sara,
parameters: {
docs: {
docPage: {
title: 'Sara',
},
},
},
};
33 changes: 33 additions & 0 deletions core/ai-components/Sara/__stories__/state.story.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react';
import { Sara, Text } from '@/index';

export const States = () => {
return (
<div className="d-flex w-75">
<div className="d-flex flex-column align-items-center text-align-center w-100">
<Sara />
<Text appearance="subtle" className="mt-6">
Default
</Text>
</div>
<div className="d-flex flex-column align-items-center text-align-center w-100">
<Sara state="resting" />
<Text appearance="subtle" className="mt-6">
Resting
</Text>
</div>
</div>
);
};

export default {
title: 'Components/AI/Sara/States',
component: Sara,
parameters: {
docs: {
docPage: {
title: 'Sara',
},
},
},
};
33 changes: 33 additions & 0 deletions core/ai-components/Sara/__tests__/Sara.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react';
import { render, fireEvent } from '@testing-library/react';
import { Sara } from '../index';

describe('Sara Component', () => {
it('renders with default props', () => {
const { getByTestId } = render(<Sara />);
const saraElement = getByTestId('DesignSystem-AI-Sara');
expect(saraElement).toBeInTheDocument();
});

it('calls onClick prop when Sara is clicked', () => {
const handleClick = jest.fn();
const { getByTestId } = render(<Sara onClick={handleClick} />);
const saraElement = getByTestId('DesignSystem-AI-Sara');
fireEvent.click(saraElement);
expect(handleClick).toHaveBeenCalledTimes(1);
});

it('applies `data-test` attribute properly', () => {
const testDataValue = 'sara-component';
const { getByTestId } = render(<Sara data-test={testDataValue} />);
const saraElement = getByTestId('sara-component');
expect(saraElement.getAttribute('data-test')).toBe(testDataValue);
});

it('applies custom className', () => {
const customClass = 'custom-sara-class';
const { getByTestId } = render(<Sara className={customClass} state="resting" />);
const saraElement = getByTestId('DesignSystem-AI-Sara');
expect(saraElement).toHaveClass(customClass);
});
});
Loading

0 comments on commit abcada2

Please sign in to comment.