Skip to content

Commit

Permalink
Fixed tests, now publicURL is in the fixture. Added one more just to …
Browse files Browse the repository at this point in the history
…be sure.
  • Loading branch information
sneridagh committed Sep 12, 2023
1 parent 9442127 commit f23da4f
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 31 deletions.
41 changes: 40 additions & 1 deletion src/components/theme/Logo/Logo.Multilingual.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import Logo from './Logo';

beforeAll(() => {
config.settings.isMultilingual = true;
config.settings.publicURL = 'http://mysite.com';
});

const mockStore = configureStore();
Expand Down Expand Up @@ -49,6 +48,7 @@ describe('Multilingual Logo', () => {
const json = component.toJSON();
expect(json).toMatchSnapshot();
});

it('renders a logo component in a multilingual site language root', () => {
const store = mockStore({
intl: {
Expand Down Expand Up @@ -85,6 +85,7 @@ describe('Multilingual Logo', () => {
const json = component.toJSON();
expect(json).toMatchSnapshot();
});

it('renders a logo component with a custom logo in a non-root url', () => {
const store = mockStore({
intl: {
Expand Down Expand Up @@ -122,4 +123,42 @@ describe('Multilingual Logo', () => {
const json = component.toJSON();
expect(json).toMatchSnapshot();
});

it('renders a logo component with a custom logo in a non-root url with path', () => {
const store = mockStore({
intl: {
locale: 'en',
messages: {},
},
navroot: {
data: {
id: 'http://localhost:3000/en/@navroot',
navroot: {
'@id': 'http://localhost:3000/en',
title: 'English',
},
},
},
router: {
location: {
pathname: '/en/my/path',
},
},
site: {
data: {
'plone.site_logo':
'http://localhost:3000/@@site-logo/logo.cab945d8.svg',
},
},
});
const component = renderer.create(
<Provider store={store}>
<MemoryRouter>
<Logo />
</MemoryRouter>
</Provider>,
);
const json = component.toJSON();
expect(json).toMatchSnapshot();
});
});
1 change: 1 addition & 0 deletions src/components/theme/Logo/Logo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const Logo = () => {

// remove trailing slash
const currentURL = toPublicURL(pathname).replace(/\/$/, '');

return (
<ConditionalLink
href={navroot?.navroot?.['@id']}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,51 +1,44 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Multilingual Logo renders a logo component in a multilingual site language root 1`] = `
<a
className={null}
href="http://localhost:3000/en"
rel="noopener noreferrer"
target="_blank"
<img
alt="English"
className="ui image"
src="Logo.svg"
title="English"
>
<img
alt="English"
className="ui image"
src="Logo.svg"
title="English"
/>
</a>
/>
`;

exports[`Multilingual Logo renders a logo component in a multilingual site root 1`] = `
<a
className={null}
href="http://localhost:3000"
rel="noopener noreferrer"
target="_blank"
<img
alt="Plone Site"
className="ui image"
src="Logo.svg"
title="Plone Site"
>
<img
alt="Plone Site"
className="ui image"
src="Logo.svg"
title="Plone Site"
/>
</a>
/>
`;

exports[`Multilingual Logo renders a logo component with a custom logo in a non-root url 1`] = `
<img
alt="English"
className="ui image"
src="/@@site-logo/logo.cab945d8.svg"
title="English"
/>
`;

exports[`Multilingual Logo renders a logo component with a custom logo in a non-root url with path 1`] = `
<a
className={null}
href="http://localhost:3000/en"
rel="noopener noreferrer"
target="_blank"
href="/en"
onClick={[Function]}
target={null}
title="English"
>
<img
alt="English"
className="ui image"
src="http://localhost:3000/@@site-logo/logo.cab945d8.svg"
src="/@@site-logo/logo.cab945d8.svg"
title="English"
/>
</a>
Expand Down

0 comments on commit f23da4f

Please sign in to comment.