2017-11-29 14:14:56 +01:00
|
|
|
/**
|
|
|
|
* Help component
|
|
|
|
*/
|
|
|
|
import React from 'react';
|
|
|
|
import { shallow } from 'enzyme';
|
2017-12-01 20:04:01 +01:00
|
|
|
import SyntaxHighlighter from 'react-syntax-highlighter/dist/light';
|
2018-06-17 13:34:59 +02:00
|
|
|
import Help from '../../../../src/webui/src/components/Help/index';
|
2017-11-29 14:14:56 +01:00
|
|
|
|
2017-12-01 20:04:01 +01:00
|
|
|
describe('<Help /> component', () => {
|
2018-01-15 23:03:43 +01:00
|
|
|
|
2017-11-29 14:14:56 +01:00
|
|
|
it('should set html from props with / base path', () => {
|
2018-01-15 23:03:43 +01:00
|
|
|
jsdom.reconfigure({
|
|
|
|
url: "http://example.com/"
|
2017-11-29 14:14:56 +01:00
|
|
|
});
|
|
|
|
const wrapper = shallow(<Help />);
|
2017-12-01 20:04:01 +01:00
|
|
|
expect(
|
|
|
|
wrapper
|
|
|
|
.find('#adduser')
|
|
|
|
.find(SyntaxHighlighter)
|
|
|
|
.dive()
|
|
|
|
.text()
|
|
|
|
).toEqual('npm adduser --registry http://example.com');
|
2017-12-02 15:01:06 +01:00
|
|
|
expect(wrapper.html()).toMatchSnapshot();
|
2017-11-29 14:14:56 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should set html from props with someOtherPath', () => {
|
2018-01-15 23:03:43 +01:00
|
|
|
jsdom.reconfigure({
|
|
|
|
url: "http://example.com/someOtherPath"
|
2017-11-29 14:14:56 +01:00
|
|
|
});
|
|
|
|
const wrapper = shallow(<Help />);
|
2017-12-01 20:04:01 +01:00
|
|
|
expect(
|
|
|
|
wrapper
|
|
|
|
.find('#publish')
|
|
|
|
.find(SyntaxHighlighter)
|
|
|
|
.dive()
|
|
|
|
.text()
|
|
|
|
).toEqual('npm publish --registry http://example.com/someOtherPath');
|
2017-12-02 15:01:06 +01:00
|
|
|
expect(wrapper.html()).toMatchSnapshot();
|
2017-11-29 14:14:56 +01:00
|
|
|
});
|
|
|
|
});
|