diff --git a/package-lock.json b/package-lock.json
index ea817f1..3f2b582 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9,7 +9,6 @@
"version": "0.1.0",
"dependencies": {
"@testing-library/jest-dom": "^5.16.2",
- "@testing-library/react": "^12.1.4",
"@testing-library/user-event": "^13.5.0",
"big.js": "^6.1.1",
"gh-pages": "^3.2.3",
@@ -24,12 +23,14 @@
"@babel/eslint-parser": "^7.17.0",
"@babel/plugin-syntax-jsx": "^7.16.7",
"@babel/preset-react": "^7.16.7",
+ "@testing-library/react": "^12.1.4",
"eslint": "^7.32.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.29.4",
"eslint-plugin-react-hooks": "^4.3.0",
+ "react-test-renderer": "^17.0.2",
"stylelint": "^13.13.1",
"stylelint-config-standard": "^21.0.0",
"stylelint-csstree-validator": "^1.9.0",
@@ -3327,6 +3328,7 @@
"version": "12.1.4",
"resolved": "https://registry.npmjs.org/@testing-library/react/-/react-12.1.4.tgz",
"integrity": "sha512-jiPKOm7vyUw311Hn/HlNQ9P8/lHNtArAx0PisXyFixDDvfl8DbD6EUdbshK5eqauvBSvzZd19itqQ9j3nferJA==",
+ "dev": true,
"dependencies": {
"@babel/runtime": "^7.12.5",
"@testing-library/dom": "^8.0.0",
@@ -3596,7 +3598,8 @@
"node_modules/@types/prop-types": {
"version": "15.7.4",
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.4.tgz",
- "integrity": "sha512-rZ5drC/jWjrArrS8BR6SIr4cWpW09RNTYt9AMZo3Jwwif+iacXAqgVjm0B0Bv/S1jhDXKHqRVNCbACkJ89RAnQ=="
+ "integrity": "sha512-rZ5drC/jWjrArrS8BR6SIr4cWpW09RNTYt9AMZo3Jwwif+iacXAqgVjm0B0Bv/S1jhDXKHqRVNCbACkJ89RAnQ==",
+ "dev": true
},
"node_modules/@types/q": {
"version": "1.5.5",
@@ -3617,6 +3620,7 @@
"version": "17.0.40",
"resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.40.tgz",
"integrity": "sha512-UrXhD/JyLH+W70nNSufXqMZNuUD2cXHu6UjCllC6pmOQgBX4SGXOH8fjRka0O0Ee0HrFxapDD8Bwn81Kmiz6jQ==",
+ "dev": true,
"dependencies": {
"@types/prop-types": "*",
"@types/scheduler": "*",
@@ -3627,6 +3631,7 @@
"version": "17.0.13",
"resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-17.0.13.tgz",
"integrity": "sha512-wEP+B8hzvy6ORDv1QBhcQia4j6ea4SFIBttHYpXKPFZRviBvknq0FRh3VrIxeXUmsPkwuXVZrVGG7KUVONmXCQ==",
+ "dev": true,
"dependencies": {
"@types/react": "*"
}
@@ -3647,7 +3652,8 @@
"node_modules/@types/scheduler": {
"version": "0.16.2",
"resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz",
- "integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew=="
+ "integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==",
+ "dev": true
},
"node_modules/@types/serve-index": {
"version": "1.9.1",
@@ -6019,7 +6025,8 @@
"node_modules/csstype": {
"version": "3.0.11",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.0.11.tgz",
- "integrity": "sha512-sa6P2wJ+CAbgyy4KFssIb/JNMLxFvKF1pCYCSXS8ZMuqZnMsrxqI2E5sPyoTpxoPU/gVZMzr2zjOfg8GIZOMsw=="
+ "integrity": "sha512-sa6P2wJ+CAbgyy4KFssIb/JNMLxFvKF1pCYCSXS8ZMuqZnMsrxqI2E5sPyoTpxoPU/gVZMzr2zjOfg8GIZOMsw==",
+ "dev": true
},
"node_modules/damerau-levenshtein": {
"version": "1.0.8",
@@ -14729,6 +14736,34 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/react-shallow-renderer": {
+ "version": "16.14.1",
+ "resolved": "https://registry.npmjs.org/react-shallow-renderer/-/react-shallow-renderer-16.14.1.tgz",
+ "integrity": "sha512-rkIMcQi01/+kxiTE9D3fdS959U1g7gs+/rborw++42m1O9FAQiNI/UNRZExVUoAOprn4umcXf+pFRou8i4zuBg==",
+ "dev": true,
+ "dependencies": {
+ "object-assign": "^4.1.1",
+ "react-is": "^16.12.0 || ^17.0.0"
+ },
+ "peerDependencies": {
+ "react": "^16.0.0 || ^17.0.0"
+ }
+ },
+ "node_modules/react-test-renderer": {
+ "version": "17.0.2",
+ "resolved": "https://registry.npmjs.org/react-test-renderer/-/react-test-renderer-17.0.2.tgz",
+ "integrity": "sha512-yaQ9cB89c17PUb0x6UfWRs7kQCorVdHlutU1boVPEsB8IDZH6n9tHxMacc3y0JoXOJUsZb/t/Mb8FUWMKaM7iQ==",
+ "dev": true,
+ "dependencies": {
+ "object-assign": "^4.1.1",
+ "react-is": "^17.0.2",
+ "react-shallow-renderer": "^16.13.1",
+ "scheduler": "^0.20.2"
+ },
+ "peerDependencies": {
+ "react": "17.0.2"
+ }
+ },
"node_modules/read-pkg": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz",
@@ -20509,6 +20544,7 @@
"version": "12.1.4",
"resolved": "https://registry.npmjs.org/@testing-library/react/-/react-12.1.4.tgz",
"integrity": "sha512-jiPKOm7vyUw311Hn/HlNQ9P8/lHNtArAx0PisXyFixDDvfl8DbD6EUdbshK5eqauvBSvzZd19itqQ9j3nferJA==",
+ "dev": true,
"requires": {
"@babel/runtime": "^7.12.5",
"@testing-library/dom": "^8.0.0",
@@ -20758,7 +20794,8 @@
"@types/prop-types": {
"version": "15.7.4",
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.4.tgz",
- "integrity": "sha512-rZ5drC/jWjrArrS8BR6SIr4cWpW09RNTYt9AMZo3Jwwif+iacXAqgVjm0B0Bv/S1jhDXKHqRVNCbACkJ89RAnQ=="
+ "integrity": "sha512-rZ5drC/jWjrArrS8BR6SIr4cWpW09RNTYt9AMZo3Jwwif+iacXAqgVjm0B0Bv/S1jhDXKHqRVNCbACkJ89RAnQ==",
+ "dev": true
},
"@types/q": {
"version": "1.5.5",
@@ -20779,6 +20816,7 @@
"version": "17.0.40",
"resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.40.tgz",
"integrity": "sha512-UrXhD/JyLH+W70nNSufXqMZNuUD2cXHu6UjCllC6pmOQgBX4SGXOH8fjRka0O0Ee0HrFxapDD8Bwn81Kmiz6jQ==",
+ "dev": true,
"requires": {
"@types/prop-types": "*",
"@types/scheduler": "*",
@@ -20789,6 +20827,7 @@
"version": "17.0.13",
"resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-17.0.13.tgz",
"integrity": "sha512-wEP+B8hzvy6ORDv1QBhcQia4j6ea4SFIBttHYpXKPFZRviBvknq0FRh3VrIxeXUmsPkwuXVZrVGG7KUVONmXCQ==",
+ "dev": true,
"requires": {
"@types/react": "*"
}
@@ -20809,7 +20848,8 @@
"@types/scheduler": {
"version": "0.16.2",
"resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz",
- "integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew=="
+ "integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==",
+ "dev": true
},
"@types/serve-index": {
"version": "1.9.1",
@@ -22548,7 +22588,8 @@
"csstype": {
"version": "3.0.11",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.0.11.tgz",
- "integrity": "sha512-sa6P2wJ+CAbgyy4KFssIb/JNMLxFvKF1pCYCSXS8ZMuqZnMsrxqI2E5sPyoTpxoPU/gVZMzr2zjOfg8GIZOMsw=="
+ "integrity": "sha512-sa6P2wJ+CAbgyy4KFssIb/JNMLxFvKF1pCYCSXS8ZMuqZnMsrxqI2E5sPyoTpxoPU/gVZMzr2zjOfg8GIZOMsw==",
+ "dev": true
},
"damerau-levenshtein": {
"version": "1.0.8",
@@ -28735,6 +28776,28 @@
}
}
},
+ "react-shallow-renderer": {
+ "version": "16.14.1",
+ "resolved": "https://registry.npmjs.org/react-shallow-renderer/-/react-shallow-renderer-16.14.1.tgz",
+ "integrity": "sha512-rkIMcQi01/+kxiTE9D3fdS959U1g7gs+/rborw++42m1O9FAQiNI/UNRZExVUoAOprn4umcXf+pFRou8i4zuBg==",
+ "dev": true,
+ "requires": {
+ "object-assign": "^4.1.1",
+ "react-is": "^16.12.0 || ^17.0.0"
+ }
+ },
+ "react-test-renderer": {
+ "version": "17.0.2",
+ "resolved": "https://registry.npmjs.org/react-test-renderer/-/react-test-renderer-17.0.2.tgz",
+ "integrity": "sha512-yaQ9cB89c17PUb0x6UfWRs7kQCorVdHlutU1boVPEsB8IDZH6n9tHxMacc3y0JoXOJUsZb/t/Mb8FUWMKaM7iQ==",
+ "dev": true,
+ "requires": {
+ "object-assign": "^4.1.1",
+ "react-is": "^17.0.2",
+ "react-shallow-renderer": "^16.13.1",
+ "scheduler": "^0.20.2"
+ }
+ },
"read-pkg": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz",
diff --git a/package.json b/package.json
index a67c34b..35ec2e8 100644
--- a/package.json
+++ b/package.json
@@ -5,7 +5,6 @@
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.16.2",
- "@testing-library/react": "^12.1.4",
"@testing-library/user-event": "^13.5.0",
"big.js": "^6.1.1",
"gh-pages": "^3.2.3",
@@ -46,12 +45,14 @@
"@babel/eslint-parser": "^7.17.0",
"@babel/plugin-syntax-jsx": "^7.16.7",
"@babel/preset-react": "^7.16.7",
+ "@testing-library/react": "^12.1.4",
"eslint": "^7.32.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.29.4",
"eslint-plugin-react-hooks": "^4.3.0",
+ "react-test-renderer": "^17.0.2",
"stylelint": "^13.13.1",
"stylelint-config-standard": "^21.0.0",
"stylelint-csstree-validator": "^1.9.0",
diff --git a/src/App.test.js b/src/App.test.js
deleted file mode 100644
index 1f03afe..0000000
--- a/src/App.test.js
+++ /dev/null
@@ -1,8 +0,0 @@
-import { render, screen } from '@testing-library/react';
-import App from './App';
-
-test('renders learn react link', () => {
- render(
+ But I must explain to you how all this mistaken idea of praising pain. I will give you a complete account of the system, and expound teachings of the great the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself but because those who do not know to pursue pleasure consequences that are painful. Nor again is there anyone who loves or pursues or desires to obtain but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has right to find fault with a man +
, ++ On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble ; and equal blame belongs to those who fail in their duty through weakness of will. as saying through shrinking from toil and pain. In a free hour, when our power of choice is untrammelled being able to do what we like best, every pleasure is to be welcomed of duty or the obligations of business it will frequently occur The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures +
, + ], + "className": "welcome", + }, + "rendered": Array [ + Object { + "instance": null, + "nodeType": "host", + "props": Object { + "children": "welcome to our page!", + }, + "rendered": Array [ + "welcome to our page!", + ], + "type": "h2", + }, + Object { + "instance": null, + "nodeType": "host", + "props": Object { + "children": "But I must explain to you how all this mistaken idea of praising pain. I will give you a complete account of the system, and expound teachings of the great the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself but because those who do not know to pursue pleasure consequences that are painful. Nor again is there anyone who loves or pursues or desires to obtain but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has right to find fault with a man", + "className": "text", + }, + "rendered": Array [ + "But I must explain to you how all this mistaken idea of praising pain. I will give you a complete account of the system, and expound teachings of the great the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself but because those who do not know to pursue pleasure consequences that are painful. Nor again is there anyone who loves or pursues or desires to obtain but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has right to find fault with a man", + ], + "type": "p", + }, + Object { + "instance": null, + "nodeType": "host", + "props": Object { + "children": "On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble ; and equal blame belongs to those who fail in their duty through weakness of will. as saying through shrinking from toil and pain. In a free hour, when our power of choice is untrammelled being able to do what we like best, every pleasure is to be welcomed of duty or the obligations of business it will frequently occur The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures", + "className": "text", + }, + "rendered": Array [ + "On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble ; and equal blame belongs to those who fail in their duty through weakness of will. as saying through shrinking from toil and pain. In a free hour, when our power of choice is untrammelled being able to do what we like best, every pleasure is to be welcomed of duty or the obligations of business it will frequently occur The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures", + ], + "type": "p", + }, + ], + "type": "div", + }, + "type": [Function], +} +`; diff --git a/src/components/__snapshots__/Nav.test.js.snap b/src/components/__snapshots__/Nav.test.js.snap new file mode 100644 index 0000000..ab510b5 --- /dev/null +++ b/src/components/__snapshots__/Nav.test.js.snap @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`renders correctly 1`] = ` + +`; diff --git a/src/components/__snapshots__/Quotes.test.js.snap b/src/components/__snapshots__/Quotes.test.js.snap new file mode 100644 index 0000000..449ee6d --- /dev/null +++ b/src/components/__snapshots__/Quotes.test.js.snap @@ -0,0 +1,130 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`renders correctly 1`] = ` +Object { + "instance": null, + "nodeType": "component", + "props": Object {}, + "rendered": Object { + "instance": null, + "nodeType": "host", + "props": Object { + "children": Array [ ++ 1. “All our dreams can come true if we have the courage to pursue them.” + + Walt Disney + +
, ++ 2. “If you hear a voice within you say ‘you cannot paint,’ then by all means paint and that voice will be silenced.” + + Vincent Van Gogh + +
, ++ 3. “It does not matter how slowly you go, so long as you do not stop.” + + Confucius + +
, + ], + "className": "quotes", + }, + "rendered": Array [ + Object { + "instance": null, + "nodeType": "host", + "props": Object { + "children": Array [ + "1. “All our dreams can come true if we have the courage to pursue them.”", + + Walt Disney + , + ], + "className": "qtext", + }, + "rendered": Array [ + "1. “All our dreams can come true if we have the courage to pursue them.”", + Object { + "instance": null, + "nodeType": "host", + "props": Object { + "children": "Walt Disney", + }, + "rendered": Array [ + "Walt Disney", + ], + "type": "span", + }, + ], + "type": "p", + }, + Object { + "instance": null, + "nodeType": "host", + "props": Object { + "children": Array [ + "2. “If you hear a voice within you say ‘you cannot paint,’ then by all means paint and that voice will be silenced.”", + + Vincent Van Gogh + , + ], + "className": "qtext", + }, + "rendered": Array [ + "2. “If you hear a voice within you say ‘you cannot paint,’ then by all means paint and that voice will be silenced.”", + Object { + "instance": null, + "nodeType": "host", + "props": Object { + "children": "Vincent Van Gogh", + }, + "rendered": Array [ + "Vincent Van Gogh", + ], + "type": "span", + }, + ], + "type": "p", + }, + Object { + "instance": null, + "nodeType": "host", + "props": Object { + "children": Array [ + "3. “It does not matter how slowly you go, so long as you do not stop.”", + + Confucius + , + ], + "className": "qtext", + }, + "rendered": Array [ + "3. “It does not matter how slowly you go, so long as you do not stop.”", + Object { + "instance": null, + "nodeType": "host", + "props": Object { + "children": "Confucius", + }, + "rendered": Array [ + "Confucius", + ], + "type": "span", + }, + ], + "type": "p", + }, + ], + "type": "div", + }, + "type": [Function], +} +`; diff --git a/src/logic/calculate.test.js b/src/logic/calculate.test.js new file mode 100644 index 0000000..8143742 --- /dev/null +++ b/src/logic/calculate.test.js @@ -0,0 +1,46 @@ +import calculate from './calculate'; + +let obj = { + total: null, + next: null, + operation: null, +}; + +describe('if calculator works well', () => { + it('subtraction works properly', () => { + obj = { + total: '4', + next: '2', + operation: '-', + }; + const { total } = calculate(obj, '='); + expect(total).toBe('2'); + }); + it('addition works properly', () => { + obj = { + total: '4', + next: '2', + operation: '+', + }; + const { total } = calculate(obj, '='); + expect(total).toBe('6'); + }); + it('division works properly', () => { + obj = { + total: '4', + next: '2', + operation: '-', + }; + const { total } = calculate(obj, '='); + expect(total).toBe('2'); + }); + it('multiplication works properly', () => { + obj = { + total: '4', + next: '2', + operation: 'x', + }; + const { total } = calculate(obj, '='); + expect(total).toBe('8'); + }); +}); diff --git a/src/logic/operate.test.js b/src/logic/operate.test.js new file mode 100644 index 0000000..6f70cd1 --- /dev/null +++ b/src/logic/operate.test.js @@ -0,0 +1,20 @@ +import operate from './operate'; + +describe('operation functions', () => { + test('division', () => { + const result = operate('10', '2', '÷'); + expect(result).toBe('5'); + }); + test('addition', () => { + const result = operate('6', '2', '+'); + expect(result).toBe('8'); + }); + test('subtraction', () => { + const result = operate('10', '5', '-'); + expect(result).toBe('5'); + }); + test('multiplication', () => { + const result = operate('2', '2', 'x'); + expect(result).toBe('4'); + }); +}); diff --git a/src/logo.svg b/src/logo.svg deleted file mode 100644 index 9dfc1c0..0000000 --- a/src/logo.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/reportWebVitals.js b/src/reportWebVitals.js deleted file mode 100644 index bb47dbb..0000000 --- a/src/reportWebVitals.js +++ /dev/null @@ -1,15 +0,0 @@ -const reportWebVitals = (onPerfEntry) => { - if (onPerfEntry && onPerfEntry instanceof Function) { - import('web-vitals').then(({ - getCLS, getFID, getFCP, getLCP, getTTFB, - }) => { - getCLS(onPerfEntry); - getFID(onPerfEntry); - getFCP(onPerfEntry); - getLCP(onPerfEntry); - getTTFB(onPerfEntry); - }); - } -}; - -export default reportWebVitals;