mirror of
https://github.com/SomboChea/ui
synced 2024-05-18 09:21:37 +07:00
97e8448098
* 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
81 lines
1.9 KiB
TypeScript
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();
|
|
});
|
|
});
|