-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: minor refactor and render tests
- Loading branch information
1 parent
ccd68d6
commit 2e26b38
Showing
2 changed files
with
78 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/views/sidebar/tests/accordion-custom-component.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 Zextras <https://www.zextras.com> | ||
* | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { faker } from '@faker-js/faker'; | ||
import { screen } from '@testing-library/react'; | ||
|
||
import { FOLDERS } from '../../../carbonio-ui-commons/constants/folders'; | ||
import { setupTest } from '../../../carbonio-ui-commons/test/test-setup'; | ||
import { Folder, FolderView } from '../../../carbonio-ui-commons/types'; | ||
import { generateStore } from '../../../tests/generators/store'; | ||
import AccordionCustomComponent from '../accordion-custom-component'; | ||
|
||
describe('AccordionCustomComponent', () => { | ||
const store = generateStore(); | ||
const folder: Folder = { | ||
id: '106', | ||
uuid: faker.string.uuid(), | ||
name: 'Confluence', | ||
absFolderPath: '/Inbox/Confluence', | ||
l: FOLDERS.INBOX, | ||
luuid: faker.string.uuid(), | ||
checked: false, | ||
f: 'u', | ||
u: 25, | ||
view: 'message' as FolderView, | ||
rev: 27896, | ||
ms: 27896, | ||
n: 37, | ||
s: 5550022, | ||
i4ms: 33607, | ||
i4next: 17183, | ||
activesyncdisabled: false, | ||
webOfflineSyncDays: 0, | ||
recursive: false, | ||
deletable: true, | ||
isLink: false, | ||
children: [], | ||
parent: undefined, | ||
depth: 2 | ||
}; | ||
|
||
it('renders the accordion item with correct label and icon', () => { | ||
setupTest(<AccordionCustomComponent item={folder} />, { store }); | ||
|
||
expect(screen.getByTestId('icon: FolderOutline')).toBeInTheDocument(); | ||
expect(screen.getByTestId(`accordion-folder-item-${folder.id}`)).toBeInTheDocument(); | ||
expect(screen.getByText('Confluence')).toBeInTheDocument(); | ||
expect(screen.getByText('25')).toBeInTheDocument(); | ||
}); | ||
|
||
it('does not render the component if the folder is broken', () => { | ||
const brokenFolder = { ...folder, isLink: true, broken: true, reminder: true }; | ||
|
||
setupTest(<AccordionCustomComponent item={brokenFolder} />, { store }); | ||
|
||
expect(screen.queryByTestId(`accordion-folder-item-${folder.id}`)).not.toBeInTheDocument(); | ||
}); | ||
}); |