diff --git a/src/components/Dist/Dist.test.tsx b/src/components/Dist/Dist.test.tsx
new file mode 100644
index 0000000..5a3a10b
--- /dev/null
+++ b/src/components/Dist/Dist.test.tsx
@@ -0,0 +1,80 @@
+import React from 'react';
+import { shallow } from 'enzyme';
+
+describe(' component', () => {
+ beforeEach(() => {
+ jest.resetModules();
+ });
+
+ test('should render the component in default state', () => {
+ const packageMeta = {
+ latest: {
+ name: 'verdaccio',
+ version: '4.0.0',
+ dist: {
+ fileCount: 7,
+ unpackedSize: 10,
+ },
+ license: '',
+ },
+ };
+ jest.doMock('../../pages/version/Version', () => ({
+ DetailContextConsumer: component => {
+ return component.children({ packageMeta });
+ },
+ }));
+
+ const Dist = require('./Dist').default;
+ const wrapper = shallow();
+ expect(wrapper.html()).toMatchSnapshot();
+ });
+
+ test('should render the component with license as string', () => {
+ const packageMeta = {
+ latest: {
+ name: 'verdaccio',
+ version: '4.0.0',
+ dist: {
+ fileCount: 7,
+ unpackedSize: 10,
+ },
+ license: 'MIT',
+ },
+ };
+ jest.doMock('../../pages/version/Version', () => ({
+ DetailContextConsumer: component => {
+ return component.children({ packageMeta });
+ },
+ }));
+
+ const Dist = require('./Dist').default;
+ const wrapper = shallow();
+ expect(wrapper.html()).toMatchSnapshot();
+ });
+
+ test('should render the component with license as object', () => {
+ const packageMeta = {
+ latest: {
+ name: 'verdaccio',
+ version: '4.0.0',
+ dist: {
+ fileCount: 7,
+ unpackedSize: 10,
+ },
+ license: {
+ type: 'MIT',
+ url: 'https://www.opensource.org/licenses/mit-license.php',
+ },
+ },
+ };
+ jest.doMock('../../pages/version/Version', () => ({
+ DetailContextConsumer: component => {
+ return component.children({ packageMeta });
+ },
+ }));
+
+ const Dist = require('./Dist').default;
+ const wrapper = shallow();
+ expect(wrapper.html()).toMatchSnapshot();
+ });
+});
diff --git a/src/components/Dist/Dist.tsx b/src/components/Dist/Dist.tsx
index 088a085..2edcfee 100644
--- a/src/components/Dist/Dist.tsx
+++ b/src/components/Dist/Dist.tsx
@@ -31,10 +31,10 @@ class Dist extends Component {
const value = dist === 'license' ? formatLicense(distDict[dist]) : distDict[dist];
const label = (
-
+ <>
{/* eslint-disable-next-line */}
{dist.replace('-', ' ')}: {value}
-
+ >
);
return ;
});
diff --git a/src/components/Dist/__snapshots__/Dist.test.tsx.snap b/src/components/Dist/__snapshots__/Dist.test.tsx.snap
new file mode 100644
index 0000000..15ebd6c
--- /dev/null
+++ b/src/components/Dist/__snapshots__/Dist.test.tsx.snap
@@ -0,0 +1,7 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[` component should render the component in default state 1`] = `"
Latest Distribution
file count: 7
size: 10.00 Bytes
"`;
+
+exports[` component should render the component with license as object 1`] = `"Latest Distribution
file count: 7
size: 10.00 Bytes
license: MIT
"`;
+
+exports[` component should render the component with license as string 1`] = `"Latest Distribution
file count: 7
size: 10.00 Bytes
license: MIT
"`;