Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
tassoevan committed Oct 15, 2024
1 parent 98552dd commit ce18557
Show file tree
Hide file tree
Showing 9 changed files with 431 additions and 89 deletions.
1 change: 1 addition & 0 deletions packages/jest-presets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"@swc/core": "~1.7.26",
"@swc/jest": "~0.2.36",
"@testing-library/jest-dom": "~6.4.8",
"@testing-library/react": "~16.0.1",
"@types/jest-axe": "~3.5.9",
"identity-obj-proxy": "~3.0.0",
"jest-axe": "~9.0.0",
Expand Down
3 changes: 3 additions & 0 deletions packages/jest-presets/src/client/jest-setup.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { TextEncoder, TextDecoder } from 'node:util';

import { configure } from '@testing-library/react';
import { toHaveNoViolations } from 'jest-axe';
import * as uuid from 'uuid';

import '@testing-library/jest-dom';

expect.extend(toHaveNoViolations);

configure({ reactStrictMode: true });

const urlByBlob = new WeakMap<Blob, string>();
const blobByUrl = new Map<string, Blob>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ type UserAutoCompleteProps = Omit<ComponentProps<typeof AutoComplete>, 'filter'>
conditions?: { [key: string]: unknown };
};

const UserAutoComplete = ({ value, onChange, ...props }: UserAutoCompleteProps): ReactElement => {
const { conditions = {} } = props;
const UserAutoComplete = ({ conditions = {}, value, onChange, ...props }: UserAutoCompleteProps): ReactElement => {
const [filter, setFilter] = useState('');
const debouncedFilter = useDebouncedValue(filter, 1000);
const usersAutoCompleteEndpoint = useEndpoint('GET', '/v1/users.autocomplete');
Expand Down
3 changes: 3 additions & 0 deletions packages/ui-client/src/helpers/anchors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ const setAnchorRefCount = (anchorElement: HTMLElement, refCount: number): void =

export const refAnchorElement = (anchorElement: HTMLElement): void => {
setAnchorRefCount(anchorElement, getAnchorRefCount(anchorElement) + 1);
if (!anchorElement.parentElement) {
document.body.appendChild(anchorElement);
}
};

export const unrefAnchorElement = (anchorElement: HTMLElement): void => {
Expand Down
20 changes: 15 additions & 5 deletions packages/ui-voip/src/components/VoipPopup/VoipPopup.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,38 @@ const mockedUseVoipSession = jest.mocked(useVoipSession);
const appRoot = mockAppRoot();

it('should properly render incoming popup', async () => {
mockedUseVoipSession.mockImplementationOnce(() => createMockVoipSession({ type: 'INCOMING' }));
mockedUseVoipSession
.mockImplementationOnce(() => createMockVoipSession({ type: 'INCOMING' }))
.mockImplementationOnce(() => createMockVoipSession({ type: 'INCOMING' }));
render(<VoipPopup />, { wrapper: appRoot.build() });

expect(screen.getByTestId('vc-popup-incoming')).toBeInTheDocument();
});

it('should properly render ongoing popup', async () => {
mockedUseVoipSession.mockImplementationOnce(() => createMockVoipSession({ type: 'ONGOING' }));
mockedUseVoipSession
.mockImplementationOnce(() => createMockVoipSession({ type: 'ONGOING' }))
.mockImplementationOnce(() => createMockVoipSession({ type: 'ONGOING' }));

render(<VoipPopup />, { wrapper: appRoot.build() });

expect(screen.getByTestId('vc-popup-ongoing')).toBeInTheDocument();
});

it('should properly render outgoing popup', async () => {
mockedUseVoipSession.mockImplementationOnce(() => createMockVoipSession({ type: 'OUTGOING' }));
mockedUseVoipSession
.mockImplementationOnce(() => createMockVoipSession({ type: 'OUTGOING' }))
.mockImplementationOnce(() => createMockVoipSession({ type: 'OUTGOING' }));

render(<VoipPopup />, { wrapper: appRoot.build() });

expect(screen.getByTestId('vc-popup-outgoing')).toBeInTheDocument();
});

it('should properly render error popup', async () => {
mockedUseVoipSession.mockImplementationOnce(() => createMockVoipSession({ type: 'ERROR' }));
mockedUseVoipSession
.mockImplementationOnce(() => createMockVoipSession({ type: 'ERROR' }))
.mockImplementationOnce(() => createMockVoipSession({ type: 'ERROR' }));

render(<VoipPopup />, { wrapper: appRoot.build() });

Expand All @@ -58,7 +66,9 @@ it('should properly render dialer popup', async () => {
});

it('should prioritize session over dialer', async () => {
mockedUseVoipSession.mockImplementationOnce(() => createMockVoipSession({ type: 'INCOMING' }));
mockedUseVoipSession
.mockImplementationOnce(() => createMockVoipSession({ type: 'INCOMING' }))
.mockImplementationOnce(() => createMockVoipSession({ type: 'INCOMING' }));

render(<VoipPopup />, { wrapper: appRoot.build() });

Expand Down
Loading

0 comments on commit ce18557

Please sign in to comment.