mirror of
https://github.com/SomboChea/ui
synced 2024-05-18 09:21:37 +07:00
67d7188cf5
* chore: update material-ui@4.x * test: update test for ActionBar and TestField * chore: add types * chore: update types * test: update test for Author * chore: fixed bunch of unit test * chore: remove unused import * chore: remove comments * chore: replace shallow my mount * chore: update git hooks * chore: fix styles * chore: update dependencies * chore: remove types material-ui
76 lines
1.7 KiB
TypeScript
76 lines
1.7 KiB
TypeScript
import React from 'react';
|
|
import { mount } from 'enzyme';
|
|
import Repository from './Repository';
|
|
|
|
jest.mock('./img/git.png', () => '');
|
|
|
|
const mockPackageMeta = jest.fn(() => ({
|
|
latest: {
|
|
homepage: 'https://verdaccio.tld',
|
|
bugs: {
|
|
url: 'https://verdaccio.tld/bugs',
|
|
},
|
|
dist: {
|
|
tarball: 'https://verdaccio.tld/download',
|
|
},
|
|
},
|
|
}));
|
|
|
|
jest.mock('../../pages/Version', () => ({
|
|
DetailContextConsumer: component => {
|
|
return component.children({ packageMeta: mockPackageMeta() });
|
|
},
|
|
}));
|
|
|
|
describe('<Repository /> component', () => {
|
|
beforeEach(() => {
|
|
jest.resetAllMocks();
|
|
});
|
|
|
|
test('should render the component in default state', () => {
|
|
const packageMeta = {
|
|
latest: {
|
|
repository: {
|
|
type: 'git',
|
|
url: 'git+https://github.com/verdaccio/ui.git',
|
|
},
|
|
},
|
|
};
|
|
|
|
// @ts-ignore
|
|
mockPackageMeta.mockImplementation(() => packageMeta);
|
|
|
|
const wrapper = mount(<Repository />);
|
|
expect(wrapper.html()).toMatchSnapshot();
|
|
});
|
|
|
|
test('should render the component in with no repository data', () => {
|
|
const packageMeta = {
|
|
latest: {},
|
|
};
|
|
|
|
// @ts-ignore
|
|
mockPackageMeta.mockImplementation(() => packageMeta);
|
|
|
|
const wrapper = mount(<Repository />);
|
|
expect(wrapper.html()).toEqual('');
|
|
});
|
|
|
|
test('should render the component in with invalid url', () => {
|
|
const packageMeta = {
|
|
latest: {
|
|
repository: {
|
|
type: 'git',
|
|
url: 'git://github.com/verdaccio/ui.git',
|
|
},
|
|
},
|
|
};
|
|
|
|
// @ts-ignore
|
|
mockPackageMeta.mockImplementation(() => packageMeta);
|
|
|
|
const wrapper = mount(<Repository />);
|
|
expect(wrapper.html()).toEqual('');
|
|
});
|
|
});
|