Skip to content

Commit

Permalink
Bump deps, switch to Yarn
Browse files Browse the repository at this point in the history
  • Loading branch information
staylor committed Sep 13, 2020
1 parent 51ce106 commit 7205b28
Show file tree
Hide file tree
Showing 22 changed files with 7,902 additions and 14,716 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2
jobs:
build:
docker:
- image: circleci/node:10.13
- image: circleci/node:12.18

steps:
- checkout
Expand All @@ -11,11 +11,11 @@ jobs:
keys:
- deps-{{ checksum "package.json" }}

- run: npm install
- run: yarn

- save_cache:
paths:
- node_modules
key: deps-{{ checksum "package.json" }}

- run: npm test
- run: yarn test
16 changes: 8 additions & 8 deletions __tests__/api/__snapshots__/client.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,17 +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 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 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 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 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 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 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 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>"`;
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>"`;
13 changes: 10 additions & 3 deletions __tests__/api/base.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ describe('base tag', () => {
render(<Helmet base={{ href: 'http://mysite.com/' }} />);

const existingTags = document.head.querySelectorAll(`base[${HELMET_ATTRIBUTE}]`);

expect(existingTags).toBeDefined();

const filteredTags = [].slice
.call(existingTags)
.filter(tag => tag.getAttribute('href') === 'http://mysite.com/');

expect(filteredTags).toHaveLength(1);
});

Expand All @@ -24,8 +26,9 @@ describe('base tag', () => {
render(<Helmet />);

const existingTags = document.head.querySelectorAll(`base[${HELMET_ATTRIBUTE}]`);

expect(existingTags).toBeDefined();
expect(existingTags.length).toEqual(0);
expect(existingTags).toHaveLength(0);
});

it("tags without 'href' are not accepted", () => {
Expand All @@ -48,7 +51,7 @@ describe('base tag', () => {
const firstTag = [].slice.call(existingTags)[0];

expect(existingTags).toBeDefined();
expect(existingTags.length).toEqual(1);
expect(existingTags).toHaveLength(1);

expect(firstTag).toBeInstanceOf(Element);
expect(firstTag.getAttribute).toBeDefined();
Expand All @@ -61,6 +64,7 @@ describe('base tag', () => {

const tagNodes = document.head.querySelectorAll(`base[${HELMET_ATTRIBUTE}]`);
const existingTags = [].slice.call(tagNodes);

expect(existingTags).toHaveLength(0);
});
});
Expand All @@ -74,11 +78,13 @@ describe('base tag', () => {
);

const existingTags = document.head.querySelectorAll(`base[${HELMET_ATTRIBUTE}]`);

expect(existingTags).toBeDefined();

const filteredTags = [].slice
.call(existingTags)
.filter(tag => tag.getAttribute('href') === 'http://mysite.com/');

expect(filteredTags).toHaveLength(1);
});

Expand Down Expand Up @@ -121,7 +127,7 @@ describe('base tag', () => {
const firstTag = [].slice.call(existingTags)[0];

expect(existingTags).toBeDefined();
expect(existingTags.length).toEqual(1);
expect(existingTags).toHaveLength(1);

expect(firstTag).toBeInstanceOf(Element);
expect(firstTag.getAttribute).toBeDefined();
Expand All @@ -138,6 +144,7 @@ describe('base tag', () => {

const tagNodes = document.head.querySelectorAll(`base[${HELMET_ATTRIBUTE}]`);
const existingTags = [].slice.call(tagNodes);

expect(existingTags).toHaveLength(0);
});
});
Expand Down
3 changes: 2 additions & 1 deletion __tests__/api/bodyAttributes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('body attributes', () => {
};

Object.keys(attributeList).forEach(attribute => {
it(attribute, () => {
it(`${attribute}`, () => {
const attrValue = attributeList[attribute];

const attr = {
Expand All @@ -43,6 +43,7 @@ describe('body attributes', () => {
const bodyTag = document.body;

const reactCompatAttr = HTML_TAG_MAP[attribute] || attribute;

expect(bodyTag.getAttribute(reactCompatAttr)).toEqual(attrValue);
expect(bodyTag.getAttribute(HELMET_ATTRIBUTE)).toEqual(reactCompatAttr);
});
Expand Down
10 changes: 6 additions & 4 deletions __tests__/api/client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Helmet.defaultProps.defer = false;

describe('onChangeClientState', () => {
describe('API', () => {
it('when handling client state change, calls the function with new state, addedTags and removedTags ', () => {
it('when handling client state change, calls the function with new state, addedTags and removedTags', () => {
const onChange = jest.fn();
render(
<div>
Expand All @@ -31,7 +31,8 @@ describe('onChangeClientState', () => {
</div>
);

expect(onChange).toBeCalled();
expect(onChange).toHaveBeenCalled();

const newState = onChange.mock.calls[0][0];
const addedTags = onChange.mock.calls[0][1];
const removedTags = onChange.mock.calls[0][2];
Expand Down Expand Up @@ -95,7 +96,7 @@ describe('onChangeClientState', () => {
});

describe('Declarative API', () => {
it('when handling client state change, calls the function with new state, addedTags and removedTags ', () => {
it('when handling client state change, calls the function with new state, addedTags and removedTags', () => {
const onChange = jest.fn();
render(
<div>
Expand All @@ -109,7 +110,8 @@ describe('onChangeClientState', () => {
</div>
);

expect(onChange).toBeCalled();
expect(onChange).toHaveBeenCalled();

const newState = onChange.mock.calls[0][0];
const addedTags = onChange.mock.calls[0][1];
const removedTags = onChange.mock.calls[0][2];
Expand Down
9 changes: 9 additions & 0 deletions __tests__/api/htmlAttributes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe('html attributes', () => {
);

const htmlTag = document.documentElement;

expect(htmlTag.getAttribute('class')).toEqual('myClassName');
expect(htmlTag.getAttribute('lang')).toEqual('en');
expect(htmlTag.getAttribute(HELMET_ATTRIBUTE)).toEqual('class,lang');
Expand All @@ -43,6 +44,7 @@ describe('html attributes', () => {
);

const htmlTag = document.documentElement;

expect(htmlTag.getAttribute('lang')).toEqual('ja');
expect(htmlTag.getAttribute(HELMET_ATTRIBUTE)).toEqual('lang');
});
Expand All @@ -57,6 +59,7 @@ describe('html attributes', () => {
);

const htmlTag = document.documentElement;

expect(htmlTag.getAttribute('amp')).toEqual('');
expect(htmlTag.getAttribute(HELMET_ATTRIBUTE)).toEqual('amp');
});
Expand All @@ -74,6 +77,7 @@ describe('html attributes', () => {
render(<Helmet />);

const htmlTag = document.documentElement;

expect(htmlTag.getAttribute('lang')).toBeNull();
expect(htmlTag.getAttribute('amp')).toBeNull();
expect(htmlTag.getAttribute(HELMET_ATTRIBUTE)).toBeNull();
Expand All @@ -100,6 +104,7 @@ describe('html attributes', () => {
);

const htmlTag = document.documentElement;

expect(htmlTag.getAttribute('amp')).toBeNull();
expect(htmlTag.getAttribute('lang')).toEqual('ja');
expect(htmlTag.getAttribute('id')).toEqual('html-tag');
Expand Down Expand Up @@ -127,6 +132,7 @@ describe('html attributes', () => {
);

const htmlTag = document.documentElement;

expect(htmlTag.getAttribute('amp')).toBeNull();
expect(htmlTag.getAttribute('lang')).toBeNull();
expect(htmlTag.getAttribute('id')).toEqual('html-tag');
Expand All @@ -144,6 +150,7 @@ describe('html attributes', () => {
render(<Helmet />);

const htmlTag = document.documentElement;

expect(htmlTag.getAttribute('test')).toEqual('test');
expect(htmlTag.getAttribute(HELMET_ATTRIBUTE)).toBeNull();
});
Expand All @@ -158,6 +165,7 @@ describe('html attributes', () => {
);

const htmlTag = document.documentElement;

expect(htmlTag.getAttribute('test')).toEqual('helmet-attr');
expect(htmlTag.getAttribute(HELMET_ATTRIBUTE)).toEqual('test');
});
Expand All @@ -174,6 +182,7 @@ describe('html attributes', () => {
render(<Helmet />);

const htmlTag = document.documentElement;

expect(htmlTag.getAttribute('test')).toBeNull();
expect(htmlTag.getAttribute(HELMET_ATTRIBUTE)).toBeNull();
});
Expand Down
7 changes: 5 additions & 2 deletions __tests__/api/meta.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ describe('meta tags', () => {

const tagNodes = document.head.querySelectorAll(`meta[${HELMET_ATTRIBUTE}]`);
const existingTags = [].slice.call(tagNodes);

expect(existingTags).toHaveLength(0);
});

Expand All @@ -271,10 +272,11 @@ describe('meta tags', () => {

const tagNodes = document.head.querySelectorAll(`meta[${HELMET_ATTRIBUTE}]`);
const existingTags = [].slice.call(tagNodes);

expect(existingTags).toHaveLength(0);

expect(console.error).toBeCalled();
expect(console.warn).toBeCalled();
expect(console.error).toHaveBeenCalled();
expect(console.warn).toHaveBeenCalled();

expect(console.warn.mock.calls[0][0]).toMatchSnapshot();

Expand Down Expand Up @@ -484,6 +486,7 @@ describe('meta tags', () => {

const tagNodes = document.head.querySelectorAll(`meta[${HELMET_ATTRIBUTE}]`);
const existingTags = [].slice.call(tagNodes);

expect(existingTags).toHaveLength(0);
});
});
Expand Down
2 changes: 2 additions & 0 deletions __tests__/api/noscript.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ describe('noscript tags', () => {

const tagNodes = document.head.querySelectorAll(`noscript[${HELMET_ATTRIBUTE}]`);
const existingTags = [].slice.call(tagNodes);

expect(existingTags).toHaveLength(0);
});
});
Expand Down Expand Up @@ -117,6 +118,7 @@ describe('noscript tags', () => {

const tagNodes = document.head.querySelectorAll(`noscript[${HELMET_ATTRIBUTE}]`);
const existingTags = [].slice.call(tagNodes);

expect(existingTags).toHaveLength(0);
});
});
Expand Down
8 changes: 6 additions & 2 deletions __tests__/api/script.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ describe('script tags', () => {

const tagNodes = document.head.querySelectorAll(`script[${HELMET_ATTRIBUTE}]`);
const existingTags = [].slice.call(tagNodes);

expect(existingTags).toHaveLength(0);
});

Expand All @@ -173,6 +174,7 @@ describe('script tags', () => {

const tagNodes = document.head.querySelectorAll(`script[${HELMET_ATTRIBUTE}]`);
const existingTags = [].slice.call(tagNodes);

expect(existingTags).toHaveLength(0);
});
});
Expand Down Expand Up @@ -225,7 +227,7 @@ describe('script tags', () => {
const existingTags = document.head.querySelectorAll(`script[${HELMET_ATTRIBUTE}]`);

expect(existingTags).toBeDefined();
expect(existingTags.length).toEqual(0);
expect(existingTags).toHaveLength(0);
});

it("tags without 'src' are not accepted", () => {
Expand All @@ -238,7 +240,7 @@ describe('script tags', () => {
const existingTags = document.head.querySelectorAll(`script[${HELMET_ATTRIBUTE}]`);

expect(existingTags).toBeDefined();
expect(existingTags.length).toEqual(0);
expect(existingTags).toHaveLength(0);
});

it('sets script tags based on deepest nested component', () => {
Expand Down Expand Up @@ -294,6 +296,7 @@ describe('script tags', () => {

const tagNodes = document.head.querySelectorAll(`script[${HELMET_ATTRIBUTE}]`);
const existingTags = [].slice.call(tagNodes);

expect(existingTags).toHaveLength(0);
});

Expand All @@ -306,6 +309,7 @@ describe('script tags', () => {

const tagNodes = document.head.querySelectorAll(`script[${HELMET_ATTRIBUTE}]`);
const existingTags = [].slice.call(tagNodes);

expect(existingTags).toHaveLength(0);
});
});
Expand Down
4 changes: 4 additions & 0 deletions __tests__/api/style.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ describe('style tags', () => {
const existingTags = [].slice.call(tagNodes);

const [firstTag, secondTag] = existingTags;

expect(existingTags).toBeDefined();
expect(existingTags).toHaveLength(2);

Expand Down Expand Up @@ -96,6 +97,7 @@ describe('style tags', () => {

const tagNodes = document.head.querySelectorAll(`style[${HELMET_ATTRIBUTE}]`);
const existingTags = [].slice.call(tagNodes);

expect(existingTags).toHaveLength(0);
});
});
Expand Down Expand Up @@ -124,6 +126,7 @@ describe('Declarative API', () => {
const existingTags = [].slice.call(tagNodes);

const [firstTag, secondTag] = existingTags;

expect(existingTags).toBeDefined();
expect(existingTags).toHaveLength(2);

Expand Down Expand Up @@ -180,6 +183,7 @@ describe('Declarative API', () => {

const tagNodes = document.head.querySelectorAll(`style[${HELMET_ATTRIBUTE}]`);
const existingTags = [].slice.call(tagNodes);

expect(existingTags).toHaveLength(0);
});
});
2 changes: 2 additions & 0 deletions __tests__/api/title.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ describe('title', () => {
);

const titleTag = document.getElementsByTagName('title')[0];

expect(document.title).toMatchSnapshot();
expect(titleTag.getAttribute('itemprop')).toEqual('name');
});
Expand Down Expand Up @@ -299,6 +300,7 @@ describe('title', () => {
);

const titleTag = document.getElementsByTagName('title')[0];

expect(document.title).toMatchSnapshot();
expect(titleTag.getAttribute('itemprop')).toEqual('name');
});
Expand Down
Loading

0 comments on commit 7205b28

Please sign in to comment.