-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add ability to obtain site name dynamically and fix tests
- Loading branch information
1 parent
ba7bd23
commit cf720d5
Showing
11 changed files
with
120 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,21 @@ | ||
import React from 'react'; | ||
import { Helmet } from 'react-helmet'; | ||
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; | ||
import { getConfig } from '@edx/frontend-platform'; | ||
|
||
import messages from './messages'; | ||
|
||
const Head = ({ intl }) => ( | ||
<Helmet> | ||
<title> | ||
{intl.formatMessage(messages['course-authoring.page.title'], { siteName: getConfig().SITE_NAME })} | ||
</title> | ||
<link rel="shortcut icon" href={getConfig().FAVICON_URL} type="image/x-icon" /> | ||
</Helmet> | ||
); | ||
|
||
Head.propTypes = { | ||
intl: intlShape.isRequired, | ||
}; | ||
|
||
export default injectIntl(Head); |
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,17 @@ | ||
import React from 'react'; | ||
import { IntlProvider } from '@edx/frontend-platform/i18n'; | ||
import { Helmet } from 'react-helmet'; | ||
import { mount } from 'enzyme'; | ||
import { getConfig } from '@edx/frontend-platform'; | ||
import Head from './Head'; | ||
|
||
describe('Head', () => { | ||
const props = {}; | ||
it('should match render title tag and favicon with the site configuration values', () => { | ||
mount(<IntlProvider locale="en"><Head {...props} /></IntlProvider>); | ||
const helmet = Helmet.peek(); | ||
expect(helmet.title).toEqual(`Course Authoring | ${getConfig().SITE_NAME}`); | ||
expect(helmet.linkTags[0].rel).toEqual('shortcut icon'); | ||
expect(helmet.linkTags[0].href).toEqual(getConfig().FAVICON_URL); | ||
}); | ||
}); |
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,11 @@ | ||
import { defineMessages } from '@edx/frontend-platform/i18n'; | ||
|
||
const messages = defineMessages({ | ||
'course-authoring.page.title': { | ||
id: 'course-authoring.page.title', | ||
defaultMessage: 'Course Authoring | {siteName}', | ||
description: 'Title tag', | ||
}, | ||
}); | ||
|
||
export default messages; |
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
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
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