Skip to content

Commit

Permalink
testing a component of setting modal (taniarascia#465)
Browse files Browse the repository at this point in the history
Co-authored-by: Tania Rascia <[email protected]>
  • Loading branch information
fistonhn and taniarascia authored Dec 7, 2020
1 parent 50b7705 commit 940a9f3
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/resources/TestID.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export enum TestID {
UUID_MENU_BAR_COPY_ICON = 'uuid-menu-bar-copy-icon',
PREVIEW_MODE = 'preview-mode',
COPY_REFERENCE_TO_NOTE = 'copy-reference-to-note',
ICON_BUTTON = 'icon-button',
ICON_BUTTON_UPLOADER = 'icon-button-uploader',
LAST_SYNCED_NOTIFICATION_SYNCING = 'last-synced-notification-syncing',
LAST_SYNCED_NOTIFICATION_UNSAVED = 'last-synced-notification-unsaved',
LAST_SYNCED_NOTIFICATION_DATE = 'last-synced-notification-date',
Expand Down
38 changes: 38 additions & 0 deletions tests/unit/client/components/SettingsModal/IconButton.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React from 'react'
import { render } from '@testing-library/react'
import '@testing-library/jest-dom'
import 'jest-extended'
import { Camera } from 'react-feather'

import { TestID } from '@resources/TestID'
import { IconButton, IconButtonProps } from '@/components/SettingsModal/IconButton'

describe('<IconButton />', () => {
it('renders the IconButton component', () => {
const enabledProps: IconButtonProps = {
handler: jest.fn,
dataTestID: TestID.ICON_BUTTON,
icon: Camera,
text: 'takeNote',
}

const component = render(<IconButton {...enabledProps} />)

expect(component).toBeTruthy()
})

it('renders the IconButton component as disabled', () => {
const disabledProps: IconButtonProps = {
handler: jest.fn,
dataTestID: TestID.ICON_BUTTON,
disabled: true,
icon: Camera,
text: 'takeNote',
}

const component = render(<IconButton {...disabledProps} />)
const button = component.queryByTestId(TestID.ICON_BUTTON)

expect(button).toBeDisabled()
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react'
import { render } from '@testing-library/react'
import '@testing-library/jest-dom'
import 'jest-extended'
import { Camera } from 'react-feather'

import { TestID } from '@resources/TestID'
import {
IconButtonUploader,
IconButtonUploaderProps,
} from '@/components/SettingsModal/IconButtonUploader'

describe('<IconButtonUploader />', () => {
it('renders the IconButtonUploader component', () => {
const enabledProps: IconButtonUploaderProps = {
handler: jest.fn,
dataTestID: TestID.ICON_BUTTON_UPLOADER,
icon: Camera,
text: 'takeNote',
accept: 'takeNote',
}

const component = render(<IconButtonUploader {...enabledProps} />)

expect(component).toBeTruthy()
})
})

0 comments on commit 940a9f3

Please sign in to comment.