diff --git a/src/components/SecondNavbar/SecondNavbar.js b/src/components/SecondNavbar/SecondNavbar.js index c9677051..9ee67d6c 100644 --- a/src/components/SecondNavbar/SecondNavbar.js +++ b/src/components/SecondNavbar/SecondNavbar.js @@ -14,7 +14,7 @@ const SecondNavbar = ({ docView, }) => ( <> - + diff --git a/src/components/SecondNavbar/SecondNavbar.test.js b/src/components/SecondNavbar/SecondNavbar.test.js new file mode 100644 index 00000000..9d4374f0 --- /dev/null +++ b/src/components/SecondNavbar/SecondNavbar.test.js @@ -0,0 +1,18 @@ +/** + * @jest-environment jsdom + */ + +import { render } from '@testing-library/react'; +import SecondNavbar from './SecondNavbar'; +import { userSession } from '../../utils/testUtil'; + +test('renders second navbar with type = dashboard', async () => { + const { getByTestId } = render( + , + ); + const navbar = getByTestId('second-navbar'); + expect(navbar).toBeInTheDocument(); +}); diff --git a/src/components/SlateToolbar/SlateToolbar.js b/src/components/SlateToolbar/SlateToolbar.js index 21c9401b..e3d4855e 100644 --- a/src/components/SlateToolbar/SlateToolbar.js +++ b/src/components/SlateToolbar/SlateToolbar.js @@ -47,6 +47,7 @@ const SlateToolbar = () => { return (
Styles}> diff --git a/src/components/SlateToolbar/SlateToolbar.test.js b/src/components/SlateToolbar/SlateToolbar.test.js new file mode 100644 index 00000000..64ab62c8 --- /dev/null +++ b/src/components/SlateToolbar/SlateToolbar.test.js @@ -0,0 +1,56 @@ +/** + * @jest-environment jsdom + */ + +import { render } from '@testing-library/react'; +import SlateToolbar from './SlateToolbar'; + +jest.mock('slate-react', () => ({ + useSlate() { + return {}; + }, +})); + +jest.mock('../../utils/slateUtil', () => ({ + BlockButton() { return
; }, + MarkButton() { return
; }, + videoURLtoEmbedURL: jest.fn, + insertVideoEmbed: jest.fn, +})); + +jest.mock('@udecode/slate-plugins', () => ({ + ToolbarImage() { return
; }, + ToolbarAlign() { return
; }, + ToolbarButton() { return
; }, + ToolbarList() { return
; }, + ToolbarLink() { return
; }, + isNodeTypeIn: jest.fn, + toggleNodeType: jest.fn, + DEFAULTS_ALIGN: { + align_left: { type: 'align_left' }, + align_center: { type: 'align_center' }, + align_right: { type: 'align_right' }, + }, + DEFAULTS_BLOCKQUOTE: { blockquote: { type: 'blockquote' } }, + DEFAULTS_CODE_BLOCK: { code_block: { type: 'code_block' } }, + DEFAULTS_HEADING: { + h1: { type: 'h1' }, + h2: { type: 'h2' }, + h3: { type: 'h3' }, + h4: { type: 'h4' }, + h5: { type: 'h5' }, + h6: { type: 'h6' }, + }, + DEFAULTS_IMAGE: {}, + DEFAULTS_LINK: {}, + DEFAULTS_LIST: { ul: { type: 'ul' }, ol: { type: 'ol' } }, + ELEMENT_MEDIA_EMBED: 'media_embed', +})); + +test('renders slate toolbar', async () => { + const { getByTestId } = render( + , + ); + const toolbar = getByTestId('slate-toolbar'); + expect(toolbar).toBeInTheDocument(); +}); diff --git a/src/utils/testUtil.js b/src/utils/testUtil.js index b846e25c..6aaccd75 100644 --- a/src/utils/testUtil.js +++ b/src/utils/testUtil.js @@ -123,7 +123,6 @@ const userSession = { expires: '2881-10-05T14:48:00.000', }; - export { adminUserSession, annotation,