Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
staylor committed Jan 2, 2018
0 parents commit 14bc312
Show file tree
Hide file tree
Showing 55 changed files with 11,225 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"presets": [
["kyt-react", {"modules": true}],
],
"plugins": [
"transform-class-properties",
"transform-es2015-modules-commonjs",
"transform-object-rest-spread",
"transform-regenerator",
]
}
5 changes: 5 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": [
"eslint-config-kyt"
]
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
29 changes: 29 additions & 0 deletions __tests__/__snapshots__/misc.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`misc API encodes special characters 1`] = `"<meta name=\\"description\\" content=\\"This is &quot;quoted&quot; text and &amp; and '.\\" data-rh=\\"true\\">"`;
exports[`misc API only adds new tags and preserves tags when rendering additional Helmet instances 1`] = `"<meta name=\\"description\\" content=\\"Test description\\" data-rh=\\"true\\">"`;
exports[`misc API only adds new tags and preserves tags when rendering additional Helmet instances 2`] = `"<link href=\\"http://localhost/style.css\\" rel=\\"stylesheet\\" type=\\"text/css\\" data-rh=\\"true\\">"`;
exports[`misc API only adds new tags and preserves tags when rendering additional Helmet instances 3`] = `"<meta name=\\"description\\" content=\\"New description\\" data-rh=\\"true\\">"`;
exports[`misc API only adds new tags and preserves tags when rendering additional Helmet instances 4`] = `"<link href=\\"http://localhost/style2.css\\" rel=\\"stylesheet\\" type=\\"text/css\\" data-rh=\\"true\\">"`;
exports[`misc API only adds new tags and preserves tags when rendering additional Helmet instances 5`] = `"<meta name=\\"description\\" content=\\"Test description\\" data-rh=\\"true\\">"`;
exports[`misc API recognizes valid tags regardless of attribute ordering 1`] = `"<meta content=\\"Test Description\\" name=\\"description\\" data-rh=\\"true\\">"`;
exports[`misc Declarative API encodes special characters 1`] = `"<meta name=\\"description\\" content=\\"This is &quot;quoted&quot; text and &amp; and '.\\" data-rh=\\"true\\">"`;
exports[`misc Declarative API only adds new tags and preserves tags when rendering additional Helmet instances 1`] = `"<meta name=\\"description\\" content=\\"Test description\\" data-rh=\\"true\\">"`;
exports[`misc Declarative API only adds new tags and preserves tags when rendering additional Helmet instances 2`] = `"<link href=\\"http://localhost/style.css\\" rel=\\"stylesheet\\" type=\\"text/css\\" data-rh=\\"true\\">"`;
exports[`misc Declarative API only adds new tags and preserves tags when rendering additional Helmet instances 3`] = `"<meta name=\\"description\\" content=\\"New description\\" data-rh=\\"true\\">"`;
exports[`misc Declarative API only adds new tags and preserves tags when rendering additional Helmet instances 4`] = `"<link href=\\"http://localhost/style2.css\\" rel=\\"stylesheet\\" type=\\"text/css\\" data-rh=\\"true\\">"`;
exports[`misc Declarative API only adds new tags and preserves tags when rendering additional Helmet instances 5`] = `"<meta name=\\"description\\" content=\\"Test description\\" data-rh=\\"true\\">"`;
exports[`misc Declarative API recognizes valid tags regardless of attribute ordering 1`] = `"<meta content=\\"Test Description\\" name=\\"description\\" data-rh=\\"true\\">"`;
5 changes: 5 additions & 0 deletions __tests__/api/__snapshots__/base.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`base tag API sets base tag based on deepest nested component 1`] = `"<base href=\\"http://mysite.com/public\\" data-rh=\\"true\\">"`;
exports[`base tag Declarative API sets base tag based on deepest nested component 1`] = `"<base href=\\"http://mysite.com/public\\" data-rh=\\"true\\">"`;
17 changes: 17 additions & 0 deletions __tests__/api/__snapshots__/client.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`onChangeClientState API when handling client state change, calls the function with new state, addedTags and removedTags 1`] = `"<base href=\\"http://mysite.com/\\" data-rh=\\"true\\">"`;
exports[`onChangeClientState API when handling client state change, calls the function with new state, addedTags and removedTags 2`] = `"<meta charset=\\"utf-8\\" data-rh=\\"true\\">"`;
exports[`onChangeClientState API when handling client state change, calls the function with new state, addedTags and removedTags 3`] = `"<link href=\\"http://localhost/helmet\\" rel=\\"canonical\\" data-rh=\\"true\\">"`;
exports[`onChangeClientState API when handling client state change, calls the function with new state, addedTags and removedTags 4`] = `"<script src=\\"http://localhost/test.js\\" type=\\"text/javascript\\" data-rh=\\"true\\"></script>"`;
exports[`onChangeClientState Declarative API when handling client state change, calls the function with new state, addedTags and removedTags 1`] = `"<base href=\\"http://mysite.com/\\" data-rh=\\"true\\">"`;
exports[`onChangeClientState Declarative API when handling client state change, calls the function with new state, addedTags and removedTags 2`] = `"<meta charset=\\"utf-8\\" data-rh=\\"true\\">"`;
exports[`onChangeClientState Declarative API when handling client state change, calls the function with new state, addedTags and removedTags 3`] = `"<link href=\\"http://localhost/helmet\\" rel=\\"canonical\\" data-rh=\\"true\\">"`;
exports[`onChangeClientState Declarative API when handling client state change, calls the function with new state, addedTags and removedTags 4`] = `"<script src=\\"http://localhost/test.js\\" type=\\"text/javascript\\" data-rh=\\"true\\"></script>"`;
49 changes: 49 additions & 0 deletions __tests__/api/__snapshots__/link.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`link tags API allows duplicate link tags if specified in the same component 1`] = `"<link rel=\\"canonical\\" href=\\"http://localhost/helmet\\" data-rh=\\"true\\">"`;
exports[`link tags API allows duplicate link tags if specified in the same component 2`] = `"<link rel=\\"canonical\\" href=\\"http://localhost/helmet/component\\" data-rh=\\"true\\">"`;
exports[`link tags API does not render tag when primary attribute is null 1`] = `"<link rel=\\"canonical\\" href=\\"http://localhost/helmet/component\\" data-rh=\\"true\\">"`;
exports[`link tags API overrides duplicate link tags with a single link tag in a nested component 1`] = `"<link rel=\\"canonical\\" href=\\"http://localhost/helmet/innercomponent\\" data-rh=\\"true\\">"`;
exports[`link tags API overrides single link tag with duplicate link tags in a nested component 1`] = `"<link rel=\\"canonical\\" href=\\"http://localhost/helmet/component\\" data-rh=\\"true\\">"`;
exports[`link tags API overrides single link tag with duplicate link tags in a nested component 2`] = `"<link rel=\\"canonical\\" href=\\"http://localhost/helmet/innercomponent\\" data-rh=\\"true\\">"`;
exports[`link tags API sets link tags based on deepest nested component 1`] = `"<link href=\\"http://localhost/style.css\\" rel=\\"stylesheet\\" type=\\"text/css\\" media=\\"all\\" data-rh=\\"true\\">"`;
exports[`link tags API sets link tags based on deepest nested component 2`] = `"<link rel=\\"canonical\\" href=\\"http://localhost/helmet/innercomponent\\" data-rh=\\"true\\">"`;
exports[`link tags API sets link tags based on deepest nested component 3`] = `"<link href=\\"http://localhost/inner.css\\" rel=\\"stylesheet\\" type=\\"text/css\\" media=\\"all\\" data-rh=\\"true\\">"`;
exports[`link tags API tags 'rel' and 'href' properly use 'rel' as the primary identification for this tag, regardless of ordering 1`] = `"<link href=\\"http://localhost/helmet/newest\\" rel=\\"canonical\\" data-rh=\\"true\\">"`;
exports[`link tags API tags with rel='stylesheet' uses the href as the primary identification of the tag, regardless of ordering 1`] = `"<link href=\\"http://localhost/style.css\\" rel=\\"stylesheet\\" type=\\"text/css\\" media=\\"all\\" data-rh=\\"true\\">"`;
exports[`link tags API tags with rel='stylesheet' uses the href as the primary identification of the tag, regardless of ordering 2`] = `"<link rel=\\"stylesheet\\" href=\\"http://localhost/inner.css\\" type=\\"text/css\\" media=\\"all\\" data-rh=\\"true\\">"`;
exports[`link tags Declarative API allows duplicate link tags if specified in the same component 1`] = `"<link rel=\\"canonical\\" href=\\"http://localhost/helmet\\" data-rh=\\"true\\">"`;
exports[`link tags Declarative API allows duplicate link tags if specified in the same component 2`] = `"<link rel=\\"canonical\\" href=\\"http://localhost/helmet/component\\" data-rh=\\"true\\">"`;
exports[`link tags Declarative API does not render tag when primary attribute is null 1`] = `"<link rel=\\"canonical\\" href=\\"http://localhost/helmet/component\\" data-rh=\\"true\\">"`;
exports[`link tags Declarative API overrides duplicate link tags with a single link tag in a nested component 1`] = `"<link rel=\\"canonical\\" href=\\"http://localhost/helmet/innercomponent\\" data-rh=\\"true\\">"`;
exports[`link tags Declarative API overrides single link tag with duplicate link tags in a nested component 1`] = `"<link rel=\\"canonical\\" href=\\"http://localhost/helmet/component\\" data-rh=\\"true\\">"`;
exports[`link tags Declarative API overrides single link tag with duplicate link tags in a nested component 2`] = `"<link rel=\\"canonical\\" href=\\"http://localhost/helmet/innercomponent\\" data-rh=\\"true\\">"`;
exports[`link tags Declarative API sets link tags based on deepest nested component 1`] = `"<link href=\\"http://localhost/style.css\\" rel=\\"stylesheet\\" type=\\"text/css\\" media=\\"all\\" data-rh=\\"true\\">"`;
exports[`link tags Declarative API sets link tags based on deepest nested component 2`] = `"<link rel=\\"canonical\\" href=\\"http://localhost/helmet/innercomponent\\" data-rh=\\"true\\">"`;
exports[`link tags Declarative API sets link tags based on deepest nested component 3`] = `"<link href=\\"http://localhost/inner.css\\" rel=\\"stylesheet\\" type=\\"text/css\\" media=\\"all\\" data-rh=\\"true\\">"`;
exports[`link tags Declarative API tags 'rel' and 'href' properly use 'rel' as the primary identification for this tag, regardless of ordering 1`] = `"<link href=\\"http://localhost/helmet/newest\\" rel=\\"canonical\\" data-rh=\\"true\\">"`;
exports[`link tags Declarative API tags with rel='stylesheet' uses the href as the primary identification of the tag, regardless of ordering 1`] = `"<link href=\\"http://localhost/style.css\\" rel=\\"stylesheet\\" type=\\"text/css\\" media=\\"all\\" data-rh=\\"true\\">"`;
exports[`link tags Declarative API tags with rel='stylesheet' uses the href as the primary identification of the tag, regardless of ordering 2`] = `"<link rel=\\"stylesheet\\" href=\\"http://localhost/inner.css\\" type=\\"text/css\\" media=\\"all\\" data-rh=\\"true\\">"`;
35 changes: 35 additions & 0 deletions __tests__/api/__snapshots__/meta.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`meta tags API allows duplicate meta tags if specified in the same component 1`] = `"<meta name=\\"description\\" content=\\"Test description\\" data-rh=\\"true\\">"`;
exports[`meta tags API allows duplicate meta tags if specified in the same component 2`] = `"<meta name=\\"description\\" content=\\"Duplicate description\\" data-rh=\\"true\\">"`;
exports[`meta tags API fails gracefully when meta is wrong shape 1`] = `"Helmet: meta should be of type \\"Array\\". Instead found type \\"object\\""`;
exports[`meta tags API overrides duplicate meta tags with single meta tag in a nested component 1`] = `"<meta name=\\"description\\" content=\\"Inner description\\" data-rh=\\"true\\">"`;
exports[`meta tags API overrides single meta tag with duplicate meta tags in a nested component 1`] = `"<meta name=\\"description\\" content=\\"Inner description\\" data-rh=\\"true\\">"`;
exports[`meta tags API overrides single meta tag with duplicate meta tags in a nested component 2`] = `"<meta name=\\"description\\" content=\\"Inner duplicate description\\" data-rh=\\"true\\">"`;
exports[`meta tags API sets meta tags based on deepest nested component 1`] = `"<meta charset=\\"utf-8\\" data-rh=\\"true\\">"`;
exports[`meta tags API sets meta tags based on deepest nested component 2`] = `"<meta name=\\"description\\" content=\\"Inner description\\" data-rh=\\"true\\">"`;
exports[`meta tags API sets meta tags based on deepest nested component 3`] = `"<meta name=\\"keywords\\" content=\\"test,meta,tags\\" data-rh=\\"true\\">"`;
exports[`meta tags Declarative API allows duplicate meta tags if specified in the same component 1`] = `"<meta name=\\"description\\" content=\\"Test description\\" data-rh=\\"true\\">"`;
exports[`meta tags Declarative API allows duplicate meta tags if specified in the same component 2`] = `"<meta name=\\"description\\" content=\\"Duplicate description\\" data-rh=\\"true\\">"`;
exports[`meta tags Declarative API overrides duplicate meta tags with single meta tag in a nested component 1`] = `"<meta name=\\"description\\" content=\\"Inner description\\" data-rh=\\"true\\">"`;
exports[`meta tags Declarative API overrides single meta tag with duplicate meta tags in a nested component 1`] = `"<meta name=\\"description\\" content=\\"Inner description\\" data-rh=\\"true\\">"`;
exports[`meta tags Declarative API overrides single meta tag with duplicate meta tags in a nested component 2`] = `"<meta name=\\"description\\" content=\\"Inner duplicate description\\" data-rh=\\"true\\">"`;
exports[`meta tags Declarative API sets meta tags based on deepest nested component 1`] = `"<meta charset=\\"utf-8\\" data-rh=\\"true\\">"`;
exports[`meta tags Declarative API sets meta tags based on deepest nested component 2`] = `"<meta name=\\"description\\" content=\\"Inner description\\" data-rh=\\"true\\">"`;
exports[`meta tags Declarative API sets meta tags based on deepest nested component 3`] = `"<meta name=\\"keywords\\" content=\\"test,meta,tags\\" data-rh=\\"true\\">"`;
5 changes: 5 additions & 0 deletions __tests__/api/__snapshots__/noscript.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`noscript tags API updates noscript tags 1`] = `"<noscript id=\\"bar\\" data-rh=\\"true\\"><link rel=\\"stylesheet\\" type=\\"text/css\\" href=\\"foo.css\\" /></noscript>"`;

exports[`noscript tags Declarative API updates noscript tags 1`] = `"<noscript id=\\"bar\\" data-rh=\\"true\\"><link rel=\\"stylesheet\\" type=\\"text/css\\" href=\\"foo.css\\" /></noscript>"`;
13 changes: 13 additions & 0 deletions __tests__/api/__snapshots__/script.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`script tags API sets script tags based on deepest nested component 1`] = `"<script src=\\"http://localhost/test.js\\" type=\\"text/javascript\\" data-rh=\\"true\\"></script>"`;
exports[`script tags API sets script tags based on deepest nested component 2`] = `"<script src=\\"http://localhost/test2.js\\" type=\\"text/javascript\\" data-rh=\\"true\\"></script>"`;
exports[`script tags API sets undefined attribute values to empty strings 1`] = `"<script src=\\"foo.js\\" async=\\"\\" data-rh=\\"true\\"></script>"`;
exports[`script tags Declarative API sets script tags based on deepest nested component 1`] = `"<script src=\\"http://localhost/test.js\\" type=\\"text/javascript\\" data-rh=\\"true\\"></script>"`;
exports[`script tags Declarative API sets script tags based on deepest nested component 2`] = `"<script src=\\"http://localhost/test2.js\\" type=\\"text/javascript\\" data-rh=\\"true\\"></script>"`;
exports[`script tags Declarative API sets undefined attribute values to empty strings 1`] = `"<script src=\\"foo.js\\" async=\\"\\" data-rh=\\"true\\"></script>"`;
33 changes: 33 additions & 0 deletions __tests__/api/__snapshots__/style.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Declarative API updates style tags 1`] = `
"<style type=\\"text/css\\" data-rh=\\"true\\">
body {
background-color: green;
}
</style>"
`;
exports[`Declarative API updates style tags 2`] = `
"<style data-rh=\\"true\\">
p {
font-size: 12px;
}
</style>"
`;
exports[`style tags updates style tags 1`] = `
"<style type=\\"text/css\\" data-rh=\\"true\\">
body {
background-color: green;
}
</style>"
`;
exports[`style tags updates style tags 2`] = `
"<style data-rh=\\"true\\">
p {
font-size: 12px;
}
</style>"
`;
53 changes: 53 additions & 0 deletions __tests__/api/__snapshots__/title.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`title API does not encode all characters with HTML character entity equivalents 1`] = `"膣膗 鍆錌雔"`;

exports[`title API merges deepest component title with nearest upstream titleTemplate 1`] = `"This is a Second Test of the titleTemplate feature"`;

exports[`title API page title with prop itemprop 1`] = `"Test Title with itemProp"`;

exports[`title API renders dollar characters in a title correctly when titleTemplate present 1`] = `"This is a te$t te$$t te$$$t te$$$$t"`;

exports[`title API replaces multiple title strings in titleTemplate 1`] = `"This is a Test of the titleTemplate feature. Another Test."`;

exports[`title API sets title based on deepest nested component 1`] = `"Nested Title"`;

exports[`title API sets title using deepest nested component with a defined title 1`] = `"Main Title"`;

exports[`title API updates page title 1`] = `"Test Title"`;

exports[`title API updates page title with multiple children 1`] = `"Child Two Title"`;

exports[`title API uses a titleTemplate based on deepest nested component 1`] = `"A Second Test using nested titleTemplate attributes"`;

exports[`title API uses a titleTemplate if defined 1`] = `"This is a Test of the titleTemplate feature"`;

exports[`title API uses defaultTitle if no title is defined 1`] = `"Fallback"`;

exports[`title Declarative API does not encode all characters with HTML character entity equivalents 1`] = `"膣膗 鍆錌雔"`;

exports[`title Declarative API merges deepest component title with nearest upstream titleTemplate 1`] = `"This is a Second Test of the titleTemplate feature"`;

exports[`title Declarative API page title with prop itemProp 1`] = `"Test Title with itemProp"`;

exports[`title Declarative API renders dollar characters in a title correctly when titleTemplate present 1`] = `"This is a te$t te$$t te$$$t te$$$$t"`;

exports[`title Declarative API replaces multiple title strings in titleTemplate 1`] = `"This is a Test of the titleTemplate feature. Another Test."`;

exports[`title Declarative API retains existing title tag when no title tag is defined 1`] = `"Existing Title"`;

exports[`title Declarative API sets title based on deepest nested component 1`] = `"Nested Title"`;

exports[`title Declarative API sets title using deepest nested component with a defined title 1`] = `"Main Title"`;

exports[`title Declarative API updates page title 1`] = `"Test Title"`;

exports[`title Declarative API updates page title and allows children containing expressions 1`] = `"Title: Some Great Title"`;

exports[`title Declarative API updates page title with multiple children 1`] = `"Child Two Title"`;

exports[`title Declarative API uses a titleTemplate based on deepest nested component 1`] = `"A Second Test using nested titleTemplate attributes"`;

exports[`title Declarative API uses a titleTemplate if defined 1`] = `"This is a Test of the titleTemplate feature"`;

exports[`title Declarative API uses defaultTitle if no title is defined 1`] = `"Fallback"`;
Loading

0 comments on commit 14bc312

Please sign in to comment.