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

adding vitest in avatar.spec.test #2603

Closed
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
82836f0
chore(deps): bump sass from 1.80.6 to 1.80.7 (#2433)
dependabot[bot] Nov 14, 2024
a97314c
chore(deps): bump eslint-plugin-import from 2.30.0 to 2.31.0 (#2434)
dependabot[bot] Nov 14, 2024
32eb6a9
chore(deps): bump @mui/x-charts from 7.22.1 to 7.22.2 (#2435)
dependabot[bot] Nov 14, 2024
ab509f6
chore(deps): bump @types/react from 18.3.3 to 18.3.12 (#2436)
dependabot[bot] Nov 14, 2024
fb913e1
Update pull-request.yml
palisadoes Nov 14, 2024
d16b95e
Update dependabot.yaml
palisadoes Nov 16, 2024
15513f5
added docker check to workflow (#2414)
VanshikaSabharwal Nov 17, 2024
3ea2919
eslint-rule-no_unused_vars (#2428)
prayanshchh Nov 17, 2024
084ac7e
Updated pr template with checklist (#2454)
dhirajudhani Nov 20, 2024
58f289b
Update pull-request-target.yml
palisadoes Nov 25, 2024
7a991b3
Update pull-request-target.yml
palisadoes Nov 25, 2024
f9e10b8
Update from develop-postgres 20241130 (#2531)
palisadoes Dec 1, 2024
9c92449
Added vitest to avatar
NishantSinghhhhh Dec 4, 2024
16efbdf
Merge branch 'develop-postgres' into develop
NishantSinghhhhh Dec 5, 2024
0b481de
Correcting linting issue
NishantSinghhhhh Dec 5, 2024
ba9a476
Merge branch 'develop' of github.com:NishantSinghhhhh/talawa-admin in…
NishantSinghhhhh Dec 5, 2024
7741661
Correcting linting issue
NishantSinghhhhh Dec 5, 2024
008db5b
Added typedoc in avatar.spec.tsx
NishantSinghhhhh Dec 5, 2024
26f9012
removing codecov error
NishantSinghhhhh Dec 5, 2024
f7b77a1
removing codecov error
NishantSinghhhhh Dec 5, 2024
750daee
Removing codecov errros
NishantSinghhhhh Dec 5, 2024
805521e
Removing codecov errros
NishantSinghhhhh Dec 5, 2024
84eb82f
removing linting errors
NishantSinghhhhh Dec 5, 2024
b1e8d07
solving codecov errors
NishantSinghhhhh Dec 6, 2024
4fbec1e
changed the extra edited file
NishantSinghhhhh Dec 6, 2024
82d94dc
typedoc added
NishantSinghhhhh Dec 6, 2024
c2465f6
Update pull_request_template.md
NishantSinghhhhh Dec 6, 2024
996b31b
added more tests in eventCalender
NishantSinghhhhh Dec 6, 2024
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
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

Check warning on line 1 in .github/pull_request_template.md

View workflow job for this annotation

GitHub Actions / Performs linting, formatting, type-checking, checking for different source and target branch

File ignored by default.
<!--
This section can be deleted after reading.

Expand Down Expand Up @@ -61,4 +61,4 @@

**Have you read the [contributing guide](https://github.com/PalisadoesFoundation/talawa-admin/blob/master/CONTRIBUTING.md)?**

<!--Yes or No-->
<!--Yes or No-->
96 changes: 96 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
"@babel/preset-env": "^7.26.0",
"@babel/preset-react": "^7.25.7",
"@babel/preset-typescript": "^7.26.0",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.0.1",
"@testing-library/user-event": "^12.1.10",
Expand Down Expand Up @@ -155,6 +156,8 @@
"postcss-modules": "^6.0.0",
"sass": "^1.80.7",
"tsx": "^4.19.1",
"typedoc": "^0.27.3",
"typescript": "^5.6.3",
"vite-plugin-svgr": "^4.2.0",
"vitest": "^2.1.5",
"whatwg-fetch": "^3.6.20"
Expand Down
72 changes: 72 additions & 0 deletions src/components/Avatar/Avatar.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import React from 'react';
import { render } from '@testing-library/react';
import '@testing-library/jest-dom';
import { describe, test, expect, vi } from 'vitest';
import Avatar from './Avatar';

/**
* Avatar.spec.tsx
* description: Test suite for the Avatar component.
* This file contains all the unit tests for the Avatar component, covering
* different test cases like rendering with props, handling custom styles,
* verifying behavior for invalid/valid sizes, and handling undefined names.
*
*/

vi.mock('state/store', () => ({
store: {
getState: vi.fn(() => ({
auth: {
user: null,
loading: false,
},
})),
subscribe: vi.fn(),
dispatch: vi.fn(),
},
}));

vi.mock('utils/i18nForTest', () => ({
__esModule: true,
default: vi.fn(() => ({
t: (key: string) => key,
})),
}));
describe('Avatar component', () => {
test('renders with name and alt attribute', () => {
const testName = 'John Doe';
const testAlt = 'Test Alt Text';
const testSize = 64;

const { getByAltText } = render(
<Avatar name={testName} alt={testAlt} size={testSize} />,
);

const avatarElement = getByAltText(testAlt);

expect(avatarElement).toBeInTheDocument();
expect(avatarElement.getAttribute('src')).toBeDefined();
});

test('renders with custom style and data-testid', () => {
const testName = 'Jane Doe';
const testStyle = 'custom-avatar-style';
const testDataTestId = 'custom-avatar-test-id';

const { getByAltText } = render(
<Avatar
name={testName}
alt="Dummy Avatar"
// className={testStyle}
data-testid={testDataTestId}
/>,
);

const avatarElement = getByAltText('Dummy Avatar');

expect(avatarElement).toBeInTheDocument();
expect(avatarElement.getAttribute('src')).toBeDefined();
expect(avatarElement.getAttribute('class')).toContain(testStyle);

Check failure on line 69 in src/components/Avatar/Avatar.spec.tsx

View workflow job for this annotation

GitHub Actions / Test Application

src/components/Avatar/Avatar.spec.tsx > Avatar component > renders with custom style and data-testid

AssertionError: expected '' to contain 'custom-avatar-style' - Expected + Received - custom-avatar-style ❯ src/components/Avatar/Avatar.spec.tsx:69:49
expect(avatarElement.getAttribute('data-testid')).toBe(testDataTestId);
});
NishantSinghhhhh marked this conversation as resolved.
Show resolved Hide resolved
});
3 changes: 2 additions & 1 deletion src/components/CheckIn/tagTemplate.ts

Large diffs are not rendered by default.

Loading