1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-13 03:35:52 +01:00
verdaccio/test/webui/components/help.spec.js

39 lines
2.1 KiB
JavaScript
Raw Normal View History

2017-11-29 14:14:56 +01:00
/**
* Help component
*/
import React from 'react';
import { shallow } from 'enzyme';
import Help from '../../../src/webui/src/components/Help';
describe('<NoItem /> component', () => {
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 />);
expect(wrapper.html()).toEqual(
'<div><li><h1>No Package Published Yet</h1><div><div>To publish your first package just:</div><br/><strong>1. Login</strong><pre style="display:block;overflow-x:auto;padding:0.5em;background:#000;color:#f8f8f8"><code>npm adduser --registry http:<span style="color:#aeaeae;font-style:italic">//example.com</span></code></pre><strong>2. Publish</strong><pre style="display:block;overflow-x:auto;padding:0.5em;background:#000;color:#f8f8f8"><code>npm publish --registry http:<span style="color:#aeaeae;font-style:italic">//example.com</span></code></pre><strong>3. Refresh this page!</strong></div></li></div>'
2017-11-29 14:14:56 +01:00
);
});
it('should set html from props with someOtherPath', () => {
Object.defineProperty(window.location, 'pathname', {
writable: true,
value: '/someOtherPath'
});
const wrapper = shallow(<Help />);
expect(wrapper.html()).toEqual('<div><li><h1>No Package Published Yet</h1><div><div>To publish your first package just:</div><br/><strong>1. Login</strong><pre style="display:block;overflow-x:auto;padding:0.5em;background:#000;color:#f8f8f8"><code>npm adduser --registry http:<span style="color:#aeaeae;font-style:italic">//example.com/someOtherPath</span></code></pre><strong>2. Publish</strong><pre style="display:block;overflow-x:auto;padding:0.5em;background:#000;color:#f8f8f8"><code>npm publish --registry http:<span style="color:#aeaeae;font-style:italic">//example.com/someOtherPath</span></code></pre><strong>3. Refresh this page!</strong></div></li></div>');
2017-11-29 14:14:56 +01:00
});
});