diff --git a/src/components/ActionBar/ActionBar.test.tsx b/src/components/ActionBar/ActionBar.test.tsx index 01c16d1..59cea7b 100644 --- a/src/components/ActionBar/ActionBar.test.tsx +++ b/src/components/ActionBar/ActionBar.test.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { mount, shallow } from 'enzyme'; describe(' component', () => { beforeEach(() => { @@ -43,6 +43,31 @@ describe(' component', () => { const ActionBar = require('./ActionBar').default; const wrapper = shallow(); + // 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(); + 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 c9a3495..902784d 100644 --- a/src/components/ActionBar/__snapshots__/ActionBar.test.tsx.snap +++ b/src/components/ActionBar/__snapshots__/ActionBar.test.tsx.snap @@ -1,3 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[` component should render the component in default state 1`] = `"
"`; + +exports[` component when there is a button to download a tarball 1`] = `"
"`;