diff --git a/package.json b/package.json
index 8fa8032..5436e3b 100644
--- a/package.json
+++ b/package.json
@@ -43,6 +43,7 @@
"prettier": "^2.3.2",
"razzle": "^4.0.6",
"razzle-dev-utils": "^4.0.6",
+ "react-test-renderer": "^17.0.2",
"stylelint": "^13.13.1",
"stylelint-config-prettier": "^8.0.2",
"webpack": "^4.44.1",
diff --git a/src/components/App/App.test.js b/src/components/App/__test__/App.test.js
similarity index 54%
rename from src/components/App/App.test.js
rename to src/components/App/__test__/App.test.js
index ca97c5e..778732f 100644
--- a/src/components/App/App.test.js
+++ b/src/components/App/__test__/App.test.js
@@ -1,7 +1,8 @@
-import App from './App';
+import App from '../App';
import React from 'react';
import ReactDOM from 'react-dom';
import { MemoryRouter } from 'react-router-dom';
+import renderer from 'react-test-renderer';
describe('', () => {
test('renders without exploding', () => {
@@ -13,4 +14,14 @@ describe('', () => {
div,
);
});
+ test(' snapshot', () => {
+ const tree = renderer
+ .create(
+
+
+ ,
+ )
+ .toJSON();
+ expect(tree).toMatchSnapshot();
+ });
});
diff --git a/src/components/App/__test__/__snapshots__/App.test.js.snap b/src/components/App/__test__/__snapshots__/App.test.js.snap
new file mode 100644
index 0000000..3fa9128
--- /dev/null
+++ b/src/components/App/__test__/__snapshots__/App.test.js.snap
@@ -0,0 +1,37 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[` snapshot 1`] = `
+
+
+
+
+
+
+ undefined
+
+
+
+
+
+
+
+`;
diff --git a/src/components/Avatar/Avatar.test.js b/src/components/Avatar/__test__/Avatar.test.js
similarity index 52%
rename from src/components/Avatar/Avatar.test.js
rename to src/components/Avatar/__test__/Avatar.test.js
index 4513a59..dd44a2c 100644
--- a/src/components/Avatar/Avatar.test.js
+++ b/src/components/Avatar/__test__/Avatar.test.js
@@ -1,10 +1,15 @@
-import Avatar from './Avatar';
+import Avatar from '../Avatar';
import React from 'react';
import ReactDOM from 'react-dom';
+import renderer from 'react-test-renderer';
describe('', () => {
test('renders without exploding', () => {
const div = document.createElement('div');
ReactDOM.render(, div);
});
+ test(' snapshot', () => {
+ const tree = renderer.create().toJSON();
+ expect(tree).toMatchSnapshot();
+ });
});
diff --git a/src/components/Avatar/__test__/__snapshots__/Avatar.test.js.snap b/src/components/Avatar/__test__/__snapshots__/Avatar.test.js.snap
new file mode 100644
index 0000000..493c7b1
--- /dev/null
+++ b/src/components/Avatar/__test__/__snapshots__/Avatar.test.js.snap
@@ -0,0 +1,7 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[` snapshot 1`] = `
+
+`;
diff --git a/src/components/Button/Button.test.js b/src/components/Button/__test__/Button.test.js
similarity index 52%
rename from src/components/Button/Button.test.js
rename to src/components/Button/__test__/Button.test.js
index 893e441..cbbfed3 100644
--- a/src/components/Button/Button.test.js
+++ b/src/components/Button/__test__/Button.test.js
@@ -1,10 +1,15 @@
-import Button from './Button';
+import Button from '../Button';
import React from 'react';
import ReactDOM from 'react-dom';
+import renderer from 'react-test-renderer';
describe('', () => {
test('renders without exploding', () => {
const div = document.createElement('div');
ReactDOM.render(, div);
});
+ test(' snapshot', () => {
+ const tree = renderer.create().toJSON();
+ expect(tree).toMatchSnapshot();
+ });
});
diff --git a/src/components/Button/__test__/__snapshots__/Button.test.js.snap b/src/components/Button/__test__/__snapshots__/Button.test.js.snap
new file mode 100644
index 0000000..3b0badd
--- /dev/null
+++ b/src/components/Button/__test__/__snapshots__/Button.test.js.snap
@@ -0,0 +1,10 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[` snapshot 1`] = `
+
+`;
diff --git a/src/components/Home/Home.test.js b/src/components/Home/__test__/Home.test.js
similarity index 52%
rename from src/components/Home/Home.test.js
rename to src/components/Home/__test__/Home.test.js
index 173530b..f3abc38 100644
--- a/src/components/Home/Home.test.js
+++ b/src/components/Home/__test__/Home.test.js
@@ -1,10 +1,15 @@
-import Home from './Home';
+import Home from '../Home';
import React from 'react';
import ReactDOM from 'react-dom';
+import renderer from 'react-test-renderer';
describe('', () => {
test('renders without exploding', () => {
const div = document.createElement('div');
ReactDOM.render(, div);
});
+ test(' snapshot', () => {
+ const tree = renderer.create().toJSON();
+ expect(tree).toMatchSnapshot();
+ });
});
diff --git a/src/components/Home/__test__/__snapshots__/Home.test.js.snap b/src/components/Home/__test__/__snapshots__/Home.test.js.snap
new file mode 100644
index 0000000..c3a1f86
--- /dev/null
+++ b/src/components/Home/__test__/__snapshots__/Home.test.js.snap
@@ -0,0 +1,33 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[` snapshot 1`] = `
+
+
+
+
+
+ undefined
+
+
+
+
+
+
+`;
diff --git a/src/components/Sort/Sort.js b/src/components/Sort/Sort.js
index 4bced74..e1ee607 100644
--- a/src/components/Sort/Sort.js
+++ b/src/components/Sort/Sort.js
@@ -1,5 +1,5 @@
-import React from 'react';
-
+import React, { memo } from 'react';
+// this will sort in descending order because data is reverse sorted before it is rendered
const Sort = ({ children }) => {
const sorted = React.Children.toArray(children).sort((a, b) => {
return b.props.order - a.props.order;
@@ -8,4 +8,4 @@ const Sort = ({ children }) => {
return sorted;
};
-export default Sort;
+export default memo(Sort);
diff --git a/src/components/Sort/Sort.test.js b/src/components/Sort/Sort.test.js
deleted file mode 100644
index 0bae42a..0000000
--- a/src/components/Sort/Sort.test.js
+++ /dev/null
@@ -1,10 +0,0 @@
-import Sort from './Sort';
-import React from 'react';
-import ReactDOM from 'react-dom';
-
-describe('', () => {
- test('renders without exploding', () => {
- const div = document.createElement('div');
- ReactDOM.render(, div);
- });
-});
diff --git a/src/components/Sort/__test__/Sort.test.js b/src/components/Sort/__test__/Sort.test.js
new file mode 100644
index 0000000..58abd56
--- /dev/null
+++ b/src/components/Sort/__test__/Sort.test.js
@@ -0,0 +1,71 @@
+import Sort from '../Sort';
+import React from 'react';
+import { render, unmountComponentAtNode } from 'react-dom';
+import Button from '../../Button/Button';
+import youtubeLogo from '../../../icons/youtube.svg';
+import twitchLogo from '../../../icons/twitch.svg';
+import linkedinLogo from '../../../icons/linkedin.svg';
+import githubLogo from '../../../icons/github.svg';
+import renderer from 'react-test-renderer';
+
+describe('', () => {
+ let container = null;
+ beforeEach(() => {
+ container = document.createElement('div');
+ document.body.appendChild(container);
+ });
+ afterEach(() => {
+ unmountComponentAtNode(container);
+ container.remove();
+ container = null;
+ });
+
+ test('renders without exploding', () => {
+ render(, container);
+ });
+
+ test('Sorts Buttons by order', () => {
+ const tree = renderer
+ .create(
+
+
+
+
+
+
+ ,
+ )
+ .toJSON();
+
+ expect(tree.length).toEqual(4);
+ expect(tree[0].props.href).toEqual('linkedin.com');
+ expect(tree[1].props.href).toEqual('github.com');
+ expect(tree[2].props.href).toEqual('twitch.tv');
+ expect(tree[3].props.href).toEqual('youtube.com');
+ expect(tree).toMatchSnapshot();
+ });
+});
diff --git a/src/components/Sort/__test__/__snapshots__/Sort.test.js.snap b/src/components/Sort/__test__/__snapshots__/Sort.test.js.snap
new file mode 100644
index 0000000..eefabd0
--- /dev/null
+++ b/src/components/Sort/__test__/__snapshots__/Sort.test.js.snap
@@ -0,0 +1,62 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[` Sorts Buttons by order 1`] = `
+Array [
+
+
+ LinkedIn
+ ,
+
+
+ GitHub
+ ,
+
+
+ Twitch
+ ,
+
+
+ YouTube
+ ,
+]
+`;
diff --git a/yarn.lock b/yarn.lock
index e168344..39872af 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -8452,16 +8452,16 @@ react-error-overlay@^6.0.7, react-error-overlay@^6.0.9:
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-6.0.9.tgz#3c743010c9359608c375ecd6bc76f35d93995b0a"
integrity sha512-nQTTcUu+ATDbrSD1BZHr5kgSD4oF8OFjxun8uAaL8RwPBacGBNPf/yAuVVdx17N8XNzRDMrZ9XcKZHCjPW+9ew==
+"react-is@^16.12.0 || ^17.0.0", react-is@^17.0.1, react-is@^17.0.2:
+ version "17.0.2"
+ resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0"
+ integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==
+
react-is@^16.6.0, react-is@^16.7.0, react-is@^16.8.1:
version "16.13.1"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
-react-is@^17.0.1:
- version "17.0.2"
- resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0"
- integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==
-
react-refresh@^0.9.0:
version "0.9.0"
resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.9.0.tgz#71863337adc3e5c2f8a6bfddd12ae3bfe32aafbf"
@@ -8496,6 +8496,24 @@ react-router@5.2.1:
tiny-invariant "^1.0.2"
tiny-warning "^1.0.0"
+react-shallow-renderer@^16.13.1:
+ version "16.14.1"
+ resolved "https://registry.yarnpkg.com/react-shallow-renderer/-/react-shallow-renderer-16.14.1.tgz#bf0d02df8a519a558fd9b8215442efa5c840e124"
+ integrity sha512-rkIMcQi01/+kxiTE9D3fdS959U1g7gs+/rborw++42m1O9FAQiNI/UNRZExVUoAOprn4umcXf+pFRou8i4zuBg==
+ dependencies:
+ object-assign "^4.1.1"
+ react-is "^16.12.0 || ^17.0.0"
+
+react-test-renderer@^17.0.2:
+ version "17.0.2"
+ resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-17.0.2.tgz#4cd4ae5ef1ad5670fc0ef776e8cc7e1231d9866c"
+ integrity sha512-yaQ9cB89c17PUb0x6UfWRs7kQCorVdHlutU1boVPEsB8IDZH6n9tHxMacc3y0JoXOJUsZb/t/Mb8FUWMKaM7iQ==
+ dependencies:
+ object-assign "^4.1.1"
+ react-is "^17.0.2"
+ react-shallow-renderer "^16.13.1"
+ scheduler "^0.20.2"
+
react@^17.0.2:
version "17.0.2"
resolved "https://registry.yarnpkg.com/react/-/react-17.0.2.tgz#d0b5cc516d29eb3eee383f75b62864cfb6800037"