diff --git a/package.json b/package.json index dbb087388..621a93e7e 100644 --- a/package.json +++ b/package.json @@ -72,6 +72,7 @@ "devDependencies": { "@next/bundle-analyzer": "^12.1.4", "@next/eslint-plugin-next": "^12.1.4", + "@testing-library/jest-dom": "^5.16.5", "@testing-library/react": "^14.0.0", "@types/dockerode": "^3.3.9", "@types/node": "17.0.1", diff --git a/src/components/AppAvatar.test.tsx b/src/components/AppAvatar.test.tsx index 014043d6f..6fe1947b0 100644 --- a/src/components/AppAvatar.test.tsx +++ b/src/components/AppAvatar.test.tsx @@ -1,52 +1,13 @@ -import { render } from '@testing-library/react'; -import { describe, expect, it } from 'vitest'; +import { render, screen, cleanup } from '@testing-library/react'; +import { describe, expect, it, afterEach } from 'vitest'; import { AppAvatar } from './AppAvatar'; describe('AppAvatar', () => { + afterEach(cleanup); + it('display placeholder when no url', () => { - const { container } = render(); + render(); - expect(container.firstChild).toMatchInlineSnapshot(` -
-
- - - -
-
- `); - }); - - it('display placeholder when valid url', () => { - const { container } = render( - - ); - - expect(container.firstChild).toMatchInlineSnapshot(` -
- -
- `); + expect(screen.getByTestId('app-avatar')).toBeDefined(); }); }); diff --git a/src/components/AppAvatar.tsx b/src/components/AppAvatar.tsx index 08ca5c7b4..e5fcbfa25 100644 --- a/src/components/AppAvatar.tsx +++ b/src/components/AppAvatar.tsx @@ -11,6 +11,7 @@ export const AppAvatar = ({ return (