Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #24480 - fix org switching on subs page
- Loading branch information
Showing
6 changed files
with
127 additions
and
32 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
webpack/components/WithOrganization/__snapshots__/withOrganization.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`subscriptions page should render select org page 1`] = ` | ||
<CheckOrg> | ||
<Header | ||
title="Select Organization" | ||
> | ||
<HelmetWrapper | ||
defer={true} | ||
encodeSpecialCharacters={true} | ||
> | ||
<SideEffect(NullComponent) | ||
defer={true} | ||
encodeSpecialCharacters={true} | ||
title="Select Organization" | ||
titleAttributes={Object {}} | ||
> | ||
<NullComponent | ||
defer={true} | ||
encodeSpecialCharacters={true} | ||
title="Select Organization" | ||
titleAttributes={Object {}} | ||
/> | ||
</SideEffect(NullComponent)> | ||
</HelmetWrapper> | ||
</Header> | ||
<Connect(withRouter(SetOrganization)) | ||
redirectPath="/test" | ||
/> | ||
</CheckOrg> | ||
`; | ||
|
||
exports[`subscriptions page should render the wrapped component 1`] = ` | ||
<CheckOrg> | ||
<WrappedComponent> | ||
<div> | ||
Wrapped! | ||
</div> | ||
</WrappedComponent> | ||
</CheckOrg> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
webpack/components/WithOrganization/withOrganization.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import toJson from 'enzyme-to-json'; | ||
import withOrganization from './withOrganization'; | ||
|
||
jest.mock('../SelectOrg/SetOrganization'); | ||
jest.mock('../../helpers/caret'); | ||
|
||
describe('subscriptions page', () => { | ||
const WrappedComponent = () => <div> Wrapped! </div>; | ||
|
||
it('should render the wrapped component', () => { | ||
global.document.getElementById = () => ({ dataset: { id: 1 } }); | ||
|
||
const Component = withOrganization(WrappedComponent, '/test'); | ||
const page = mount(<Component />); | ||
expect(toJson(page)).toMatchSnapshot(); | ||
}); | ||
|
||
it('should render select org page', () => { | ||
global.document.getElementById = () => ({ dataset: { id: '' } }); | ||
|
||
const Component = withOrganization(WrappedComponent, '/test'); | ||
const page = mount(<Component />); | ||
expect(toJson(page)).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,11 @@ | ||
import React from 'react'; | ||
import { Route } from 'react-router-dom'; | ||
import { links } from './config'; | ||
import Header from './Headers'; | ||
|
||
export default () => ( | ||
<div> | ||
{links.map(({ path, component, text }) => { | ||
const Page = component; | ||
const withHeader = () => ( | ||
<React.Fragment> | ||
<Header title={text} /> | ||
<Page /> | ||
</React.Fragment> | ||
); | ||
|
||
return ( | ||
<Route exact key={path} path={`/${path}`} component={withHeader} /> | ||
); | ||
})} | ||
{links.map(({ path, component }) => ( | ||
<Route exact key={path} path={`/${path}`} component={component} /> | ||
))} | ||
</div> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react'; | ||
import Header from '../Application/Headers'; | ||
|
||
function withHeader(WrappedComponent, tags) { | ||
const Headers = props => ( | ||
<React.Fragment> | ||
<Header {...tags} /> | ||
<WrappedComponent {...props} /> | ||
</React.Fragment> | ||
); | ||
|
||
return Headers; | ||
} | ||
|
||
export default withHeader; |