1
0
Fork 1
mirror of https://github.com/SomboChea/ui synced 2024-05-18 09:21:37 +07:00
verdaccio-ui/src/components/Dist/Dist.test.tsx
Juan Picado @jotadeveloper 97e8448098
fix: refactoring version page / fix issue not found page #100 (#117)
* chore: refactoring version page

* refactor: migrate version page to hooks

* refactor: Version page better imports

* fix: #100 render not found on click item

* test: add test for version page

* chore: update mocks

* test: add scenario for not found package

* chore: fix wrong mock path

* chore: update mock

* chore: add todo list
2019-08-25 14:34:27 +02:00

81 lines
1.9 KiB
TypeScript

import React from 'react';
import { shallow } from 'enzyme';
describe('<Dist /> 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', () => ({
DetailContextConsumer: component => {
return component.children({ packageMeta });
},
}));
const Dist = require('./Dist').default;
const wrapper = shallow(<Dist />);
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', () => ({
DetailContextConsumer: component => {
return component.children({ packageMeta });
},
}));
const Dist = require('./Dist').default;
const wrapper = shallow(<Dist />);
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', () => ({
DetailContextConsumer: component => {
return component.children({ packageMeta });
},
}));
const Dist = require('./Dist').default;
const wrapper = shallow(<Dist />);
expect(wrapper.html()).toMatchSnapshot();
});
});