diff --git a/test/webui/components/help.spec.js b/test/webui/components/help.spec.js new file mode 100644 index 000000000..0be599f85 --- /dev/null +++ b/test/webui/components/help.spec.js @@ -0,0 +1,38 @@ +/** + * Help component + */ + +import React from 'react'; +import { shallow } from 'enzyme'; +import Help from '../../../src/webui/src/components/Help'; + +describe(' 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(); + expect(wrapper.html()).toEqual( + '
  • No Package Published Yet

    To publish your first package just:

    1. Login
    npm adduser --registry  http://example.com
    2. Publish
    npm publish --registry http://example.com
    3. Refresh this page!

  • ' + ); + }); + + it('should set html from props with someOtherPath', () => { + Object.defineProperty(window.location, 'pathname', { + writable: true, + value: '/someOtherPath' + }); + const wrapper = shallow(); + expect(wrapper.html()).toEqual('
  • No Package Published Yet

    To publish your first package just:

    1. Login
    npm adduser --registry  http://example.com/someOtherPath
    2. Publish
    npm publish --registry http://example.com/someOtherPath
    3. Refresh this page!

  • '); + }); +});