Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("creates correct 404 meta and title data", () => {
// Given
const meta = [
{ name: "description", content: "" },
{ name: "prerender-status-code", content: "404" },
]
const title = "Page Not Found"
const links = []
wrapper = mount()
// Then
expect(Helmet.peek().metaTags).toEqual(meta)
expect(Helmet.peek().linkTags).toEqual(links)
expect(Helmet.peek().title).toEqual(titleTemplate(title))
})
})
it("creates correct meta, link, and title data", () => {
// Given
const meta = [{ name: "description", content: "Test description" }]
const title = "Test title"
const links = [{ rel: "canonical", href: jestConfig.testURL }]
wrapper = mount()
// Then
expect(Helmet.peek().metaTags).toEqual(meta)
expect(Helmet.peek().linkTags).toEqual(links)
expect(Helmet.peek().title).toEqual(titleTemplate(title))
})
before(() => {
// Tell helmet to run as if it's a server render.
// This is caused by the jsdom env.
Helmet.canUseDOM = false;
return runTestServer({ app: 'amo' })
.then((server) => {
app = server;
});
});
const React = require('react');
const Helmet = require('react-helmet').default;
const projectShape = require('./projectshape.jsx').projectShape;
const Meta = props => {
const {title, instructions, author} = props.projectInfo;
// Do not want to render any meta tags unless all the info is loaded
// Check only author (object) because it is ok to have empty string instructions
if (!author) return null;
const truncatedInstructions = instructions.split(' ')
.slice(0, 50)
.join(' ');
return (
.then(() => {
const reduxState = escape(JSON.stringify(getState()));
const css = new Set();
/* eslint-disable no-underscore-dangle */
const html = ReactDOMServer.renderToString(
{ css.add(styles._getCss()); }}>
{ }
);
const head = Helmet.rewind();
res.render('index', {
html,
reduxState,
inlineCss: arrayFrom(css).join(''),
head,
isMobile,
});
})
.catch(err => next(err));
getRenderProps(feature, params.url).then(nr.createTracer('getRenderProps', (renderProps) => {
let html = null
try {
html = renderToString()
} catch (ex) {
// throw new Error(`Error: 3 - Could Not Render ${feature} view`, ex)
Raven.captureException(ex)
nr.endTransaction()
res.status(500).send({ error: 3, message: `Could Not Render ${feature} view`, ex, stack: ex.stack })
}
const initialState = Object.assign({}, startingState, store.getState(), { hosts: { nodeHost: getNodeHost(req), railsHost: params.railsHost } })
let head = Helmet.rewind()
head = {
base: head.base.toString(),
meta: head.meta.toString(),
link: head.link.toString(),
title: head.title.toString(),
script: head.script.toString()
}
// for lookinside stuff
let referrer = null
if (params.referrer) {
referrer = params.referrer
}
res.setHeader('Cache-Control', 'public')
// in development mode
if (__DEVSERVER__) {
config.link = config.link.filter(l => l.rel !== 'stylesheet');
}
const Meta = () => (
)
ReactDOMServer.renderToString();
const header = Helmet.rewind();
export default header;
const html = ({
protocol, // http or https
style, // raw styles to be embedded directly into the document
scripts, // scripts to be linked in the document body
state, // initial state of the client side store
children, // output of server side route render
}) => {
const head = Helmet.rewind();
return (
{head.base.toComponent()}
{head.title.toComponent()}
{head.meta.toComponent()}
{head.link.toComponent()}
{head.script.toComponent()}
{style &&
export default (store: Store, htmlApp: string = '') => {
const head = Helmet.rewind();
const assets = webpackIsomorphicTools.assets();
// Setup html page
return `
${head.base.toString()}
${head.title.toString()}
${head.meta.toString()}
render () {
const {assets, component, store} = this.props
const content = component ? ReactDOM.renderToString(component) : ''
const helmet = Helmet.rewind()
return (
{helmet.base.toComponent()}
{helmet.title.toComponent()}
{helmet.meta.toComponent()}
{helmet.link.toComponent()}
{helmet.script.toComponent()}
{/* styles (will be present only in production with webpack extract text plugin) */}