main

mattermost/focalboard

Last updated at: 29/12/2023 09:41

shareBoardButton.test.tsx

TLDR

This file is a test file for the ShareBoardButton component. It includes tests for rendering the component with different props and checking if the rendered output matches the snapshot.

Methods

No methods in this file.

Classes

No classes in this file.

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {render} from '@testing-library/react'
import React from 'react'
import {Provider as ReduxProvider} from 'react-redux'

import {BoardTypeOpen} from '../../blocks/board'

import {TestBlockFactory} from '../../test/testBlockFactory'
import {wrapDNDIntl, mockStateStore} from '../../testUtils'

import ShareBoardButton from './shareBoardButton'

jest.useFakeTimers()

const boardId = '1'

const board = TestBlockFactory.createBoard()
board.id = boardId

describe('src/components/shareBoard/shareBoard', () => {
    const state = {
        boards: {
            boards: {
                [board.id]: board,
            },
            current: board.id,
        },
    }

    const store = mockStateStore([], state)

    test('should match snapshot, Private Board', async () => {
        const result = render(
            wrapDNDIntl(
                <ReduxProvider store={store}>
                    <ShareBoardButton
                        enableSharedBoards={true}
                    />
                </ReduxProvider>))

        const renderer = result.container

        expect(renderer).toMatchSnapshot()
    })

    test('should match snapshot, Open Board', async () => {
        board.type = BoardTypeOpen
        const result = render(
            wrapDNDIntl(
                <ReduxProvider store={store}>
                    <ShareBoardButton
                        enableSharedBoards={true}
                    />
                </ReduxProvider>))

        const renderer = result.container

        expect(renderer).toMatchSnapshot()
    })
})