1
0
mirror of https://github.com/SomboChea/ui synced 2026-01-21 02:26:00 +07:00

test: add scenario for action bar

Wether the metadata has a tarball distribution file
This commit is contained in:
Juan Picado @jotadeveloper
2019-07-29 00:12:14 +02:00
parent 62431038bb
commit 8c9cffbc6a
2 changed files with 28 additions and 1 deletions

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { mount, shallow } from 'enzyme';
describe('<ActionBar /> component', () => {
beforeEach(() => {
@@ -43,6 +43,31 @@ describe('<ActionBar /> component', () => {
const ActionBar = require('./ActionBar').default;
const wrapper = shallow(<ActionBar />);
// FIXME: this only renders the DetailContextConsumer, thus
// the wrapper will be
expect(wrapper.html()).toEqual('');
});
test('when there is a button to download a tarball', () => {
const packageMeta = {
latest: {
dist: {
tarball: 'http://localhost:8080/bootstrap/-/bootstrap-4.3.1.tgz',
},
},
};
jest.doMock('../../pages/version/Version', () => ({
DetailContextConsumer: component => {
return component.children({ packageMeta });
},
}));
const ActionBar = require('./ActionBar').default;
const wrapper = mount(<ActionBar />);
expect(wrapper.html()).toMatchSnapshot();
const button = wrapper.find('button');
expect(button).toHaveLength(1);
});
});