12345678910111213141516171819202122232425262728293031323334 |
- import {render, screen} from 'sentry-test/reactTestingLibrary';
- import LastCommit from 'sentry/components/lastCommit';
- describe('LastCommit', function () {
- let mockedCommit;
- const mockedCommitTitle = '(improve) Add Links to Spike-Protection Email (#2408)';
- beforeEach(() => {
- mockedCommit = TestStubs.Commit();
- });
- it('renders', function () {
- const wrapper = render(<LastCommit commit={mockedCommit} />);
- expect(wrapper.container).toSnapshot();
- });
- it('links to the commit in GitHub', function () {
- mockedCommit.repository.provider = {id: 'github'};
- const mockedCommitURL = `${mockedCommit.repository?.url}/commit/${mockedCommit.id}`;
- render(<LastCommit commit={mockedCommit} />);
- expect(screen.getByText(mockedCommitTitle)).toBeInTheDocument();
- expect(screen.getByText(mockedCommitTitle)).toHaveAttribute('href', mockedCommitURL);
- });
- it('displays the commit with its shortened ID if it has no message', function () {
- mockedCommit.message = null;
- render(<LastCommit commit={mockedCommit} />);
- expect(screen.queryByText(mockedCommitTitle)).not.toBeInTheDocument();
- expect(screen.getByText(mockedCommit.id.slice(0, 7))).toBeInTheDocument();
- });
- });
|