Chore: transfer TimeSyncButton.test to testing-library (#48404)

This commit is contained in:
L-M-K-B 2022-05-02 11:20:12 +02:00 committed by GitHub
parent 0a87ef06af
commit b8460051a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 11 deletions

View File

@ -230,9 +230,6 @@ exports[`no enzyme tests`] = {
"public/app/features/explore/SecondaryActions.test.tsx:1177396128": [
[0, 19, 13, "RegExp match", "2409514259"]
],
"public/app/features/explore/TimeSyncButton.test.tsx:853739820": [
[0, 17, 13, "RegExp match", "2409514259"]
],
"public/app/features/folders/FolderSettingsPage.test.tsx:1109052730": [
[0, 19, 13, "RegExp match", "2409514259"]
],

View File

@ -1,20 +1,20 @@
import { mount } from 'enzyme';
import { render, screen } from '@testing-library/react';
import React from 'react';
import { TimeSyncButton } from './TimeSyncButton';
const setup = (isSynced: boolean) => {
const onClick = () => {};
return mount(<TimeSyncButton onClick={onClick} isSynced={isSynced} />);
return render(<TimeSyncButton onClick={onClick} isSynced={isSynced} />);
};
describe('TimeSyncButton', () => {
it('should change style when synced', () => {
const wrapper = setup(true);
expect(wrapper.find('button').props()['aria-label']).toEqual('Synced times');
it('should have the right name when isSynced = true', () => {
setup(true);
expect(screen.getByRole('button', { name: /synced times/i })).toBeInTheDocument();
});
it('should not change style when not synced', () => {
const wrapper = setup(false);
expect(wrapper.find('button').props()['aria-label']).toEqual('Unsynced times');
it('should have the right name when isSynced = false', () => {
setup(false);
expect(screen.getByRole('button', { name: /unsynced times/i })).toBeInTheDocument();
});
});