Skip to content

Commit

Permalink
♻️ update tests to use vitest and react-testing-library
Browse files Browse the repository at this point in the history
  • Loading branch information
mihailgaberov committed Dec 31, 2023
1 parent 93d3acb commit 5541aa3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/components/Nickname/Nickname.test.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import {shallow} from 'enzyme';
import { render, screen, fireEvent } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import * as React from 'react';

import Nickname from './Nickname';

const setup = (username = '') => {
return shallow(<Nickname value={username}/>)
return render(<Nickname value={username}/>)
};

describe('Nickname component', () => {
describe('Nickname', () => {
it('renders without crashing', () => {
const wrapper = setup();
expect(wrapper).not.toBe(null)
});

it('should render user name if given', () => {
let wrapper = setup();
expect(wrapper.text()).toBe('');
wrapper = setup('guest0001');
expect(wrapper.text()).toBe('guest0001');
setup('guest0001');
expect(screen.getByText('guest0001')).toBeVisible();
});
});

0 comments on commit 5541aa3

Please sign in to comment.