diff --git a/src/components/ActionBar/ActionBar.test.tsx b/src/components/ActionBar/ActionBar.test.tsx index 2d0d677..6f09cae 100644 --- a/src/components/ActionBar/ActionBar.test.tsx +++ b/src/components/ActionBar/ActionBar.test.tsx @@ -1,6 +1,8 @@ import React from 'react'; import { mount } from 'enzyme'; +import api from '../../utils/api'; + import { ActionBar } from './ActionBar'; const mockPackageMeta: jest.Mock = jest.fn(() => ({ @@ -43,6 +45,12 @@ describe(' component', () => { expect(wrapper.html()).toEqual(''); }); + test('when there is no latest property in package meta', () => { + mockPackageMeta.mockImplementation(() => ({})); + const wrapper = mount(); + expect(wrapper.html()).toEqual(''); + }); + test('when there is a button to download a tarball', () => { mockPackageMeta.mockImplementation(() => ({ latest: { @@ -57,5 +65,25 @@ describe(' component', () => { const button = wrapper.find('button'); expect(button).toHaveLength(1); + + const spy = jest.spyOn(api, 'request'); + button.simulate('click'); + expect(spy).toHaveBeenCalled(); + }); + + test('when there is a button to open an issue', () => { + mockPackageMeta.mockImplementation(() => ({ + latest: { + bugs: { + url: 'https://verdaccio.tld/bugs', + }, + }, + })); + + const wrapper = mount(); + expect(wrapper.html()).toMatchSnapshot(); + + const button = wrapper.find('button'); + expect(button).toHaveLength(1); }); }); diff --git a/src/components/ActionBar/__snapshots__/ActionBar.test.tsx.snap b/src/components/ActionBar/__snapshots__/ActionBar.test.tsx.snap index b6c99f4..95729a8 100644 --- a/src/components/ActionBar/__snapshots__/ActionBar.test.tsx.snap +++ b/src/components/ActionBar/__snapshots__/ActionBar.test.tsx.snap @@ -3,3 +3,5 @@ exports[` component should render the component in default state 1`] = `""`; exports[` component when there is a button to download a tarball 1`] = `"
"`; + +exports[` component when there is a button to open an issue 1`] = `"
"`;