1
0
mirror of https://github.com/SomboChea/ui synced 2026-01-20 01:55:56 +07:00

refactor: adds download tarball spec to action bar (#220)

* refactor: adds download tarball spec to action bar

* refactor: fixes typo
This commit is contained in:
Ayush Sharma
2019-10-26 12:02:03 +02:00
committed by Juan Picado @jotadeveloper
parent ae0222cf65
commit 52ed8ad67b
2 changed files with 30 additions and 0 deletions

View File

@@ -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('<ActionBar /> component', () => {
expect(wrapper.html()).toEqual('');
});
test('when there is no latest property in package meta', () => {
mockPackageMeta.mockImplementation(() => ({}));
const wrapper = mount(<ActionBar />);
expect(wrapper.html()).toEqual('');
});
test('when there is a button to download a tarball', () => {
mockPackageMeta.mockImplementation(() => ({
latest: {
@@ -57,5 +65,25 @@ describe('<ActionBar /> 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(<ActionBar />);
expect(wrapper.html()).toMatchSnapshot();
const button = wrapper.find('button');
expect(button).toHaveLength(1);
});
});