All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.resources.js.tests.ObjectActions.CheckboxParameter.spec.tsx Maven / Gradle / Ivy

The newest version!
/**
 * SPDX-FileCopyrightText: (c) 2024 Liferay, Inc. https://liferay.com
 * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
 */

import '@testing-library/jest-dom/extend-expect';
import {render, screen} from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import React from 'react';

import {CheckboxParameter} from '../../components/ObjectAction/tabs/ActionContainer/CheckboxParameter';

describe('The CheckboxParameter component should', () => {
	it('return the checked value', () => {
		render(
			 {
					expect(checked).toStrictEqual(true);
				}}
				title="Automatically relate object entries involved in the action"
			/>
		);

		userEvent.click(screen.getByRole('checkbox'));
	});

	it('return the unchecked value', () => {
		render(
			 {
					expect(checked).toStrictEqual(false);
				}}
				title="Automatically relate object entries involved in the action"
			/>
		);

		userEvent.click(screen.getByRole('checkbox'));
	});

	it('render the checkbox checked', () => {
		render(
			 {
					expect(checked).toStrictEqual(true);
				}}
				title="Automatically relate object entries involved in the action"
			/>
		);

		expect(screen.getByRole('checkbox')).toBeChecked();
	});

	it('render the checkbox unchecked', () => {
		render(
			 {
					expect(checked).toStrictEqual(true);
				}}
				title="Automatically relate object entries involved in the action"
			/>
		);

		expect(screen.getByRole('checkbox')).not.toBeChecked();
	});

	it('render the disabled checkbox', () => {
		render(
			 {
					expect(checked).toStrictEqual(true);
				}}
				title="Automatically relate object entries involved in the action"
			/>
		);

		expect(screen.getByRole('checkbox')).toBeDisabled();
	});

	it('render the label', () => {
		render(
			 {
					expect(checked).toStrictEqual(true);
				}}
				title="Automatically relate object entries involved in the action"
			/>
		);

		expect(screen.getByText('also relate entries')).toBeInTheDocument();
	});

	it('render the title', () => {
		render(
			 {
					expect(checked).toStrictEqual(true);
				}}
				title="Automatically relate object entries involved in the action"
			/>
		);

		expect(
			screen.getByTitle(
				'Automatically relate object entries involved in the action'
			)
		).toBeInTheDocument();
	});
});




© 2015 - 2025 Weber Informatics LLC | Privacy Policy