0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-01-27 22:59:51 -05:00
verdaccio/test/webui/components/help.spec.js

51 lines
1.3 KiB
JavaScript
Raw Normal View History

2017-11-29 18:44:56 +05:30
/**
* Help component
*/
import React from 'react';
import { shallow } from 'enzyme';
2017-12-02 00:34:01 +05:30
import SyntaxHighlighter from 'react-syntax-highlighter/dist/light';
2017-11-29 18:44:56 +05:30
import Help from '../../../src/webui/src/components/Help';
2017-12-02 00:34:01 +05:30
describe('<Help /> component', () => {
2017-11-29 18:44:56 +05:30
beforeEach(() => {
/**
* @see https://github.com/facebook/jest/issues/890
*/
Object.defineProperty(window.location, 'origin', {
writable: true,
value: 'http://example.com'
});
});
it('should set html from props with / base path', () => {
Object.defineProperty(window.location, 'pathname', {
writable: true,
value: '/'
});
const wrapper = shallow(<Help />);
2017-12-02 00:34:01 +05:30
expect(
wrapper
.find('#adduser')
.find(SyntaxHighlighter)
.dive()
.text()
).toEqual('npm adduser --registry http://example.com');
expect(wrapper.html()).toMatchSnapshot();
2017-11-29 18:44:56 +05:30
});
it('should set html from props with someOtherPath', () => {
Object.defineProperty(window.location, 'pathname', {
writable: true,
value: '/someOtherPath'
});
const wrapper = shallow(<Help />);
2017-12-02 00:34:01 +05:30
expect(
wrapper
.find('#publish')
.find(SyntaxHighlighter)
.dive()
.text()
).toEqual('npm publish --registry http://example.com/someOtherPath');
expect(wrapper.html()).toMatchSnapshot();
2017-11-29 18:44:56 +05:30
});
});