2019-04-05 02:23:40 +07:00
|
|
|
import React from 'react';
|
|
|
|
import { shallow } from 'enzyme';
|
|
|
|
|
2019-06-20 19:37:28 +07:00
|
|
|
describe('<Author /> component', () => {
|
2019-07-03 02:37:36 +07:00
|
|
|
beforeEach(() => {
|
|
|
|
jest.resetModules();
|
|
|
|
});
|
|
|
|
|
2019-04-05 02:23:40 +07:00
|
|
|
test('should render the component in default state', () => {
|
2019-07-03 02:37:36 +07:00
|
|
|
const packageMeta = {
|
|
|
|
latest: {
|
|
|
|
name: 'verdaccio',
|
|
|
|
version: '4.0.0',
|
|
|
|
author: {
|
|
|
|
name: 'verdaccio user',
|
|
|
|
email: 'verdaccio.user@verdaccio.org',
|
|
|
|
url: '',
|
|
|
|
avatar: 'https://www.gravatar.com/avatar/000000',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
jest.doMock('../../pages/version/Version', () => ({
|
|
|
|
DetailContextConsumer: component => {
|
|
|
|
return component.children({ packageMeta });
|
|
|
|
},
|
|
|
|
}));
|
|
|
|
|
|
|
|
const Author = require('./Author').default;
|
|
|
|
const wrapper = shallow(<Author />);
|
|
|
|
expect(wrapper.html()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
test('should render the component when there is no author information available', () => {
|
|
|
|
const packageMeta = {
|
|
|
|
latest: {
|
|
|
|
name: 'verdaccio',
|
|
|
|
version: '4.0.0',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
jest.doMock('../../pages/version/Version', () => ({
|
|
|
|
DetailContextConsumer: component => {
|
|
|
|
return component.children({ packageMeta });
|
|
|
|
},
|
|
|
|
}));
|
|
|
|
|
|
|
|
const Author = require('./Author').default;
|
|
|
|
const wrapper = shallow(<Author />);
|
|
|
|
expect(wrapper.html()).toEqual('');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('should render the component when there is no author email', () => {
|
|
|
|
const packageMeta = {
|
|
|
|
latest: {
|
|
|
|
name: 'verdaccio',
|
|
|
|
version: '4.0.0',
|
|
|
|
author: {
|
|
|
|
name: 'verdaccio user',
|
|
|
|
url: '',
|
|
|
|
avatar: 'https://www.gravatar.com/avatar/000000',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
jest.doMock('../../pages/version/Version', () => ({
|
|
|
|
DetailContextConsumer: component => {
|
|
|
|
return component.children({ packageMeta });
|
|
|
|
},
|
|
|
|
}));
|
|
|
|
|
|
|
|
const Author = require('./Author').default;
|
2019-06-20 19:37:28 +07:00
|
|
|
const wrapper = shallow(<Author />);
|
2019-04-05 02:23:40 +07:00
|
|
|
expect(wrapper.html()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|