From d3148449c925d5b17047a5b37e31dd631fd3f525 Mon Sep 17 00:00:00 2001 From: kenneth051 Date: Fri, 30 Nov 2018 02:39:01 +0300 Subject: [PATCH] ft():Users should create entries Authenticated users should create, view and update articles[Delivers #162330363] --- package-lock.json | 214 +++++++++++++------- package.json | 4 + src/App.css | 3 +- src/App.js | 8 + src/actions/ActionTypes.js | 2 - src/actions/ActionTypes.jsx | 6 + src/actions/AuthAction.js | 45 ---- src/actions/AuthAction.jsx | 117 +++++++++++ src/component/CreateEntry.jsx | 14 ++ src/component/EntryForm.jsx | 35 ++++ src/component/Footer.jsx | 9 + src/component/GetEntries.jsx | 69 +++++++ src/component/Main.jsx | 86 ++++++++ src/component/Navbar.jsx | 9 + src/component/Notfound.jsx | 6 +- src/component/{register.js => Register.jsx} | 2 +- src/component/SingleEntry.jsx | 68 +++++++ src/component/UpdateEntry.jsx | 44 ++++ src/component/footer.js | 13 -- src/component/{login.js => login.jsx} | 9 +- src/component/menu.jsx | 11 + src/component/navbar.js | 13 -- src/container/landingpage.js | 55 ----- src/container/landingpage.jsx | 55 +++++ src/index.css | 54 ++++- src/index.js | 5 +- src/reducers/EntryReducer.js | 23 +++ src/reducers/index.jsx | 2 + src/{ => tests}/App.test.js | 2 +- src/tests/Entry.test.jsx | 85 ++++++++ src/tests/EntryReducers.test.jsx | 54 +++++ src/tests/functions.test.jsx | 6 + src/tests/index.test.jsx | 9 + 33 files changed, 931 insertions(+), 206 deletions(-) delete mode 100644 src/actions/ActionTypes.js create mode 100644 src/actions/ActionTypes.jsx delete mode 100644 src/actions/AuthAction.js create mode 100644 src/actions/AuthAction.jsx create mode 100644 src/component/CreateEntry.jsx create mode 100644 src/component/EntryForm.jsx create mode 100644 src/component/Footer.jsx create mode 100644 src/component/GetEntries.jsx create mode 100644 src/component/Main.jsx create mode 100644 src/component/Navbar.jsx rename src/component/{register.js => Register.jsx} (99%) create mode 100644 src/component/SingleEntry.jsx create mode 100644 src/component/UpdateEntry.jsx delete mode 100644 src/component/footer.js rename src/component/{login.js => login.jsx} (89%) create mode 100644 src/component/menu.jsx delete mode 100644 src/component/navbar.js delete mode 100644 src/container/landingpage.js create mode 100644 src/container/landingpage.jsx create mode 100644 src/reducers/EntryReducer.js rename src/{ => tests}/App.test.js (89%) create mode 100644 src/tests/Entry.test.jsx create mode 100644 src/tests/EntryReducers.test.jsx create mode 100644 src/tests/functions.test.jsx create mode 100644 src/tests/index.test.jsx diff --git a/package-lock.json b/package-lock.json index ad528a6..a7e2e46 100644 --- a/package-lock.json +++ b/package-lock.json @@ -891,8 +891,7 @@ "@types/node": { "version": "10.12.10", "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.10.tgz", - "integrity": "sha512-8xZEYckCbUVgK8Eg7lf5Iy4COKJ5uXlnIOnePN0WUwSQggy9tolM+tDJf7wMOnT/JT/W9xDYIaYggt3mRV2O5w==", - "dev": true + "integrity": "sha512-8xZEYckCbUVgK8Eg7lf5Iy4COKJ5uXlnIOnePN0WUwSQggy9tolM+tDJf7wMOnT/JT/W9xDYIaYggt3mRV2O5w==" }, "@types/tapable": { "version": "1.0.2", @@ -1127,9 +1126,9 @@ "integrity": "sha512-z55ocwKBRLryBs394Sm3ushTtBeg6VAeuku7utSoSnsJKvKcnXFIyC6vh27n3rXyxSgkJBBCAvyOn7gSUcTYjg==" }, "ajv": { - "version": "6.5.5", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.5.5.tgz", - "integrity": "sha512-7q7gtRQDJSyuEHjuVgHoUa2VuemFiCMrfQc9Tc08XTAc4Zj/5U1buQJ0HU6i7fKjXU09SVgSmxa4sLvuvS8Iyg==", + "version": "6.6.1", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.6.1.tgz", + "integrity": "sha512-ZoJjft5B+EJBjUyu9C9Hc0OZyPZSSlOF+plzouTrg6UlA8f+e/n8NIgBFG/9tppJtpPWfthHakK7juJdNDODww==", "requires": { "fast-deep-equal": "^2.0.1", "fast-json-stable-stringify": "^2.0.0", @@ -2228,6 +2227,11 @@ "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.12.0.tgz", "integrity": "sha512-DYWGk01lDcxeS/K9IHPGWfT8PsJmbXRtRd2Sx72Tnb8pcYZQFF1oSDb8hJtS1vhp212q1Rzi5dUf9+nq0o9UIg==" }, + "blacklist": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/blacklist/-/blacklist-1.1.4.tgz", + "integrity": "sha1-st0J1hd2JbLKppg1o3somV+povI=" + }, "bluebird": { "version": "3.5.3", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.3.tgz", @@ -2436,6 +2440,13 @@ "base64-js": "^1.0.2", "ieee754": "^1.1.4", "isarray": "^1.0.0" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + } } }, "buffer-from": { @@ -2673,15 +2684,6 @@ } } }, - "parse5": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-3.0.3.tgz", - "integrity": "sha512-rgO9Zg5LLLkfJF9E6CCmXlSE4UVceloys8JrFqCcHloC3usd/kJCyPDwH2SOlzix2j3xaP9sUX3e8+kvkuleAA==", - "dev": true, - "requires": { - "@types/node": "*" - } - }, "readable-stream": { "version": "3.0.6", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.0.6.tgz", @@ -4389,6 +4391,11 @@ "isarray": "^1.0.0" } }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, "load-json-file": { "version": "2.0.0", "resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", @@ -4702,6 +4709,11 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" } } }, @@ -5153,6 +5165,11 @@ "repeat-string": "^1.5.2" }, "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, "isobject": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", @@ -6444,16 +6461,6 @@ "resolve-pathname": "^2.2.0", "value-equal": "^0.4.0", "warning": "^3.0.0" - }, - "dependencies": { - "warning": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/warning/-/warning-3.0.0.tgz", - "integrity": "sha1-MuU3fLVy3kqwR1O9+IIcAe1gW3w=", - "requires": { - "loose-envify": "^1.0.0" - } - } } }, "hmac-drbg": { @@ -6599,11 +6606,6 @@ "domelementtype": "1" } }, - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" - }, "readable-stream": { "version": "1.0.34", "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", @@ -7434,9 +7436,9 @@ "integrity": "sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0=" }, "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" }, "isemail": { "version": "3.2.0", @@ -8155,6 +8157,13 @@ "whatwg-url": "^7.0.0", "ws": "^6.1.0", "xml-name-validator": "^3.0.0" + }, + "dependencies": { + "parse5": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-5.1.0.tgz", + "integrity": "sha512-fxNG2sQjHvlVAYmzBZS9YlDp6PTSSDwa98vkD4QgVDDCAo84z5X1t5XyJQ62ImdLXx5NdIIfihey6xpum9/gRQ==" + } } }, "jsesc": { @@ -8432,6 +8441,11 @@ "integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA=", "dev": true }, + "lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=" + }, "lodash.memoize": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", @@ -8494,12 +8508,12 @@ "integrity": "sha1-miyr0bno4K6ZOkv31YdcOcQujqw=" }, "lru-cache": { - "version": "4.1.4", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.4.tgz", - "integrity": "sha512-EPstzZ23znHUVLKj+lcXO1KvZkrlw+ZirdwvOmnAnA/1PB4ggyXJ77LRkCqkff+ShQ+cqoxCxLQOh4cKITO5iA==", + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", + "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", "requires": { "pseudomap": "^1.0.2", - "yallist": "^3.0.2" + "yallist": "^2.1.2" } }, "make-dir": { @@ -8576,6 +8590,11 @@ "resolved": "http://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" }, + "medium-editor": { + "version": "5.23.3", + "resolved": "https://registry.npmjs.org/medium-editor/-/medium-editor-5.23.3.tgz", + "integrity": "sha512-he9/TdjX8f8MGdXGfCs8AllrYnqXJJvjNkDKmPg3aPW/uoIrlRqtkFthrwvmd+u4QyzEiadhCCM0EwTiRdUCJw==" + }, "mem": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/mem/-/mem-1.1.0.tgz", @@ -8960,9 +8979,9 @@ } }, "node-releases": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.0.4.tgz", - "integrity": "sha512-GqRV9GcHw8JCRDaP/JoeNMNzEGzHAknMvIHqMb2VeTOmg1Cf9+ej8bkV12tHfzWHQMCkQ5zUFgwFUkfraynNCw==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.0.5.tgz", + "integrity": "sha512-Ky7q0BO1BBkG/rQz6PkEZ59rwo+aSfhczHP1wwq8IowoVdN/FpiP7qp0XW0P2+BVCWe5fQUBozdbVd54q1RbCQ==", "requires": { "semver": "^5.3.0" } @@ -9320,9 +9339,9 @@ "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=" }, "pako": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.6.tgz", - "integrity": "sha512-lQe48YPsMJAig+yngZ87Lus+NF+3mtu7DVOBu6b/gHO1YpKwIj5AWjZ/TOS7i46HD/UixzWb1zeWDZfGZ3iYcg==" + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.7.tgz", + "integrity": "sha512-3HNK5tW4x8o5mO8RuHZp3Ydw9icZXx0RANAOMzlMzx7LVXhMJ4mo3MOBpzyd7r/+RUu8BmndP47LXT+vzjtWcQ==" }, "parallel-transform": { "version": "1.1.0", @@ -9380,9 +9399,12 @@ "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=" }, "parse5": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-5.1.0.tgz", - "integrity": "sha512-fxNG2sQjHvlVAYmzBZS9YlDp6PTSSDwa98vkD4QgVDDCAo84z5X1t5XyJQ62ImdLXx5NdIIfihey6xpum9/gRQ==" + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-3.0.3.tgz", + "integrity": "sha512-rgO9Zg5LLLkfJF9E6CCmXlSE4UVceloys8JrFqCcHloC3usd/kJCyPDwH2SOlzix2j3xaP9sUX3e8+kvkuleAA==", + "requires": { + "@types/node": "*" + } }, "parseurl": { "version": "1.3.2", @@ -9430,9 +9452,12 @@ "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" }, "path-to-regexp": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", - "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.7.0.tgz", + "integrity": "sha1-Wf3g9DW62suhA6hOnTvGTpa5k30=", + "requires": { + "isarray": "0.0.1" + } }, "path-type": { "version": "1.1.0", @@ -9511,9 +9536,9 @@ "integrity": "sha512-CPCdcFxx7fEcDMWTDjXe2Wypt4JuMt4q5Q2UrpTcyBBkLiCIyPEh/mCGmUWIcNkKGyXwQ9Y2wVhlKm6ketiBNQ==" }, "popper.js": { - "version": "1.14.5", - "resolved": "https://registry.npmjs.org/popper.js/-/popper.js-1.14.5.tgz", - "integrity": "sha512-fs4Sd8bZLgEzrk8aS7Em1qh+wcawtE87kRUJQhK6+LndyV1HerX7+LURzAylVaTyWIn5NTB/lyjnWqw/AZ6Yrw==" + "version": "1.14.6", + "resolved": "https://registry.npmjs.org/popper.js/-/popper.js-1.14.6.tgz", + "integrity": "sha512-AGwHGQBKumlk/MDfrSOf0JHhJCImdDMcGNoqKmKkU+68GFazv3CQ6q9r7Ja1sKDZmYWTckY/uLyEznheTDycnA==" }, "portfinder": { "version": "1.0.19", @@ -11542,6 +11567,11 @@ "whatwg-fetch": "3.0.0" } }, + "react-attr-converter": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/react-attr-converter/-/react-attr-converter-0.3.1.tgz", + "integrity": "sha512-dSxo2Mn6Zx4HajeCeQNLefwEO4kNtV/0E682R1+ZTyFRPqxDa5zYb5qM/ocqw9Bxr/kFQO0IUiqdV7wdHw+Cdg==" + }, "react-dev-utils": { "version": "6.1.1", "resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-6.1.1.tgz", @@ -11667,6 +11697,16 @@ "resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz", "integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA==" }, + "react-medium-editor": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/react-medium-editor/-/react-medium-editor-1.8.1.tgz", + "integrity": "sha1-AW/8O7gvk2SvFffkO+ddaIJVX1o=", + "requires": { + "blacklist": "^1.1.2", + "medium-editor": "^5.10.0", + "object-assign": "^4.0.1" + } + }, "react-redux": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-5.1.1.tgz", @@ -11681,6 +11721,15 @@ "react-lifecycles-compat": "^3.0.0" } }, + "react-render-html": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/react-render-html/-/react-render-html-0.6.0.tgz", + "integrity": "sha512-F9Xn8Iy2oJvepMdDrN+XUPOwqv3ni856ikuvu/dyJ2guozN01vF0C55Ja+CQfnziQNlLevSVXzuQKYa/mhyjAQ==", + "requires": { + "parse5": "^3.0.2", + "react-attr-converter": "^0.3.1" + } + }, "react-router": { "version": "4.3.1", "resolved": "https://registry.npmjs.org/react-router/-/react-router-4.3.1.tgz", @@ -11700,17 +11749,12 @@ "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-2.5.5.tgz", "integrity": "sha512-rqcy4pJo55FTTLWt+bU8ukscqHeE/e9KWvsOW2b/a3afxQZhwkQdT1rPPCJ0rYXdj4vNcasY8zHTH+jF/qStxw==" }, - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" - }, - "path-to-regexp": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.7.0.tgz", - "integrity": "sha1-Wf3g9DW62suhA6hOnTvGTpa5k30=", + "warning": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/warning/-/warning-4.0.2.tgz", + "integrity": "sha512-wbTp09q/9C+jJn4KKJfJfoS6VleK/Dti0yqWSm6KMvJ4MRCXFQNapHuJXutJIrWV0Cf4AhTdeIe4qdKHR1+Hug==", "requires": { - "isarray": "0.0.1" + "loose-envify": "^1.0.0" } } } @@ -11726,6 +11770,16 @@ "prop-types": "^15.6.1", "react-router": "^4.3.1", "warning": "^4.0.1" + }, + "dependencies": { + "warning": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/warning/-/warning-4.0.2.tgz", + "integrity": "sha512-wbTp09q/9C+jJn4KKJfJfoS6VleK/Dti0yqWSm6KMvJ4MRCXFQNapHuJXutJIrWV0Cf4AhTdeIe4qdKHR1+Hug==", + "requires": { + "loose-envify": "^1.0.0" + } + } } }, "react-scripts": { @@ -11866,6 +11920,13 @@ "safe-buffer": "~5.1.1", "string_decoder": "~1.1.1", "util-deprecate": "~1.0.1" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + } } }, "readdirp": { @@ -12161,6 +12222,14 @@ "symbol-observable": "^1.2.0" } }, + "redux-mock-store": { + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/redux-mock-store/-/redux-mock-store-1.5.3.tgz", + "integrity": "sha512-ryhkkb/4D4CUGpAV2ln1GOY/uh51aczjcRz9k2L2bPx/Xja3c5pSGJJPyR25GNVRXtKIExScdAgFdiXp68GmJA==", + "requires": { + "lodash.isplainobject": "^4.0.6" + } + }, "redux-thunk": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-2.3.0.tgz", @@ -13780,9 +13849,9 @@ "integrity": "sha512-9I2ydhj8Z9veORCw5PRm4u9uebCn0mcCa6scWoNcbZ6dAtoo2618u9UUzxgmsCOreJpqDDuv61LvwofW7hLcBA==" }, "terser": { - "version": "3.10.12", - "resolved": "https://registry.npmjs.org/terser/-/terser-3.10.12.tgz", - "integrity": "sha512-3ODPC1eVt25EVNb04s/PkHxOmzKBQUF6bwwuR6h2DbEF8/j265Y1UkwNtOk9am/pRxfJ5HPapOlUlO6c16mKQQ==", + "version": "3.10.13", + "resolved": "https://registry.npmjs.org/terser/-/terser-3.10.13.tgz", + "integrity": "sha512-AgdHqw2leuADuHiP4Kkk1i40m10RMGguPaiCw6MVD6jtDR7N94zohGqAS2lkDXIS7eIkGit3ief3eQGh/Md+GQ==", "requires": { "commander": "~2.17.1", "source-map": "~0.6.1", @@ -14344,6 +14413,11 @@ "version": "0.1.4", "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=" + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" } } }, @@ -14516,9 +14590,9 @@ } }, "warning": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/warning/-/warning-4.0.2.tgz", - "integrity": "sha512-wbTp09q/9C+jJn4KKJfJfoS6VleK/Dti0yqWSm6KMvJ4MRCXFQNapHuJXutJIrWV0Cf4AhTdeIe4qdKHR1+Hug==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/warning/-/warning-3.0.0.tgz", + "integrity": "sha1-MuU3fLVy3kqwR1O9+IIcAe1gW3w=", "requires": { "loose-envify": "^1.0.0" } @@ -15405,9 +15479,9 @@ "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=" }, "yallist": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", - "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", + "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=" }, "yargs": { "version": "11.1.0", diff --git a/package.json b/package.json index eda2ed1..0b5fe62 100644 --- a/package.json +++ b/package.json @@ -4,16 +4,20 @@ "private": true, "dependencies": { "bootstrap": "^4.1.3", + "history": "^4.7.2", "jquery": "^3.3.1", "popper.js": "^1.14.5", "react": "^16.6.3", "react-dom": "^16.6.3", "react-flash-message": "^1.0.2", + "react-medium-editor": "^1.8.1", "react-redux": "^5.1.0", + "react-render-html": "^0.6.0", "react-router-dom": "^4.3.1", "react-scripts": "2.1.1", "react-toastify": "^4.4.3", "redux": "^4.0.1", + "redux-mock-store": "^1.5.3", "redux-thunk": "^2.3.0", "yarn": "^1.12.3" }, diff --git a/src/App.css b/src/App.css index 164a50b..425f1ff 100644 --- a/src/App.css +++ b/src/App.css @@ -1,6 +1,7 @@ html { width:100%; - height:100%; + min-height:100%; + max-height:auto; } body{ background-image: url('./images/image.jpg'); diff --git a/src/App.js b/src/App.js index 63f3c92..dbddfb4 100644 --- a/src/App.js +++ b/src/App.js @@ -3,6 +3,10 @@ import { Provider } from 'react-redux'; import { BrowserRouter, Route, Switch } from 'react-router-dom'; import store from './store'; import Landingpage from './container/landingpage'; +import CreateEntries from './component/CreateEntry'; +import UpdateEntry from './component/UpdateEntry'; +import GetEntries from './component/GetEntries'; +import ViewEntry from './component/SingleEntry'; import notFound from './component/Notfound'; import './App.css'; @@ -14,6 +18,10 @@ class App extends Component { + + + + diff --git a/src/actions/ActionTypes.js b/src/actions/ActionTypes.js deleted file mode 100644 index 91b7f6f..0000000 --- a/src/actions/ActionTypes.js +++ /dev/null @@ -1,2 +0,0 @@ -export const SIGNUP = 'SIGNUP'; -export const LOGIN = 'LOGIN'; diff --git a/src/actions/ActionTypes.jsx b/src/actions/ActionTypes.jsx new file mode 100644 index 0000000..b66232b --- /dev/null +++ b/src/actions/ActionTypes.jsx @@ -0,0 +1,6 @@ +export const SIGNUP = 'SIGNUP'; +export const LOGIN = 'LOGIN'; +export const CREATE_ENTRY = 'CREATE_ENTRY'; +export const FETCH_ENTRIES = 'FETCH_ENTRIES'; +export const SINGLE_ENTRY = 'SINGLE_ENTRY'; +export const UPDATE_ENTRY = 'UPDATE_ENTRY'; diff --git a/src/actions/AuthAction.js b/src/actions/AuthAction.js deleted file mode 100644 index f58eff2..0000000 --- a/src/actions/AuthAction.js +++ /dev/null @@ -1,45 +0,0 @@ - -import { - SIGNUP, LOGIN, -} from './ActionTypes'; - - -const baseurl = 'http://localhost:5000'; - -// const myHeaders = new Headers({ -// Accept: 'application/json', -// 'Content-type': 'application/json', -// Token: localStorage.getItem('token'), -// }); - -export const signUpUser = userData => dispatch => fetch(`${baseurl}/API/v1/auth/user/signup`, { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-type': 'application/json', - }, - body: JSON.stringify(userData), -}) - .then(res => res.json()) - .then((data) => { - dispatch({ - type: SIGNUP, - payload: data, - }); - }); - -export const loginUser = loginData => dispatch => fetch(`${baseurl}/API/v1/auth/users/login`, { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-type': 'application/json', - }, - body: JSON.stringify(loginData), -}) - .then(res => res.json()) - .then((data) => { - dispatch({ - type: LOGIN, - payload: data, - }); - }); diff --git a/src/actions/AuthAction.jsx b/src/actions/AuthAction.jsx new file mode 100644 index 0000000..eab46e4 --- /dev/null +++ b/src/actions/AuthAction.jsx @@ -0,0 +1,117 @@ + +import { + SIGNUP, LOGIN, CREATE_ENTRY, FETCH_ENTRIES, SINGLE_ENTRY, UPDATE_ENTRY, +} from './ActionTypes'; + + +const baseurl = 'http://localhost:5000'; + +// const myHeaders = new Headers({ +// Accept: 'application/json', +// 'Content-type': 'application/json', +// Token: localStorage.getItem('token'), +// }); + +export const signUpUser = userData => dispatch => fetch(`${baseurl}/API/v1/auth/user/signup`, { + method: 'POST', + headers: { + Accept: 'application/json', + 'Content-type': 'application/json', + }, + body: JSON.stringify(userData), +}) + .then(res => res.json()) + .then((data) => { + dispatch({ + type: SIGNUP, + payload: data, + }); + }); + +export const loginUser = loginData => dispatch => fetch(`${baseurl}/API/v1/auth/users/login`, { + method: 'POST', + headers: { + Accept: 'application/json', + 'Content-type': 'application/json', + }, + body: JSON.stringify(loginData), +}) + .then(res => res.json()) + .then((data) => { + dispatch({ + type: LOGIN, + payload: data, + }); + }); + +export const CreateEntries = entryData => dispatch => fetch(`${baseurl}/API/v1/entries`, { + method: 'POST', + cache: 'no-cache', + headers: { + Accept: 'application/json', + 'Content-type': 'application/json', + Authorization: `Bearer ${localStorage.getItem('token')}`, + }, + body: JSON.stringify(entryData), +}) + .then(res => res.json()) + .then((data) => { + dispatch({ + type: CREATE_ENTRY, + payload: data, + }); + }); + +export const fetchEntries = () => dispatch => fetch(`${baseurl}/API/v1/entries`, { + method: 'GET', + cache: 'no-cache', + headers: { + Accept: 'application/json', + 'Content-type': 'application/json', + Authorization: `Bearer ${localStorage.getItem('token')}`, + }, +}) + .then(res => res.json()) + .then(data => dispatch({ + type: FETCH_ENTRIES, + payload: data, + })); + +export const singleEntry = id => dispatch => fetch(`${baseurl}/API/v1/entries/${id}`, { + method: 'GET', + cache: 'no-cache', + headers: { + Accept: 'application/json', + 'Content-type': 'application/json', + Authorization: `Bearer ${localStorage.getItem('token')}`, + }, +}) + .then((res) => { + if (res.status === 404) { + window.location = '/404'; + } else { + return res.json(); + } + }) + .then(data => dispatch({ + type: SINGLE_ENTRY, + payload: data, + })); + +export const UpdateEntries = (updateData, id) => dispatch => fetch(`${baseurl}/API/v1/entries/${id}`, { + method: 'PUT', + cache: 'no-cache', + headers: { + Accept: 'application/json', + 'Content-type': 'application/json', + Authorization: `Bearer ${localStorage.getItem('token')}`, + }, + body: JSON.stringify(updateData), +}) + .then(res => res.json()) + .then((data) => { + dispatch({ + type: UPDATE_ENTRY, + payload: data, + }); + }); diff --git a/src/component/CreateEntry.jsx b/src/component/CreateEntry.jsx new file mode 100644 index 0000000..fcae5a6 --- /dev/null +++ b/src/component/CreateEntry.jsx @@ -0,0 +1,14 @@ +import React from 'react'; +import Main from './Main'; +const CreateEntries = props => ( +
+
+
+); + +export default CreateEntries; diff --git a/src/component/EntryForm.jsx b/src/component/EntryForm.jsx new file mode 100644 index 0000000..1e09c37 --- /dev/null +++ b/src/component/EntryForm.jsx @@ -0,0 +1,35 @@ +import React, { Component } from 'react'; +import Navbar from './Navbar' +import Footer from './Footer' +import Editor from 'react-medium-editor'; +require('medium-editor/dist/css/medium-editor.css'); +require('medium-editor/dist/css/themes/default.css'); +class EntryForm extends Component { + state = { }; + render() { + return ( +
{this.props.actionType}
+
+
+
+ +
+
+ +
+
+
+
+
+ ); + } +} + +export default EntryForm; diff --git a/src/component/Footer.jsx b/src/component/Footer.jsx new file mode 100644 index 0000000..5988a9d --- /dev/null +++ b/src/component/Footer.jsx @@ -0,0 +1,9 @@ +import React from 'react'; + +const Footer = () => ( +
+ Keno 2018 +
+); + +export default Footer; diff --git a/src/component/GetEntries.jsx b/src/component/GetEntries.jsx new file mode 100644 index 0000000..0830be9 --- /dev/null +++ b/src/component/GetEntries.jsx @@ -0,0 +1,69 @@ +import React, { Component } from 'react'; +import {connect} from 'react-redux'; +import { Link } from 'react-router-dom'; +import renderHTML from 'react-render-html'; +import Navbar from './Navbar' +import Footer from './Footer'; +import Menu from './menu'; +import { + fetchEntries, + } from '../actions/AuthAction'; +class GetEntries extends Component { + state = { + title:"", + body:"" + } + componentWillMount(){ + this.props.fetchEntries() + } + + render() { + const data=this.props.entry.entries.result; + console.log(data) + let showArticles; + if(data){ + showArticles = data.map(entry => ( +
+
+ +
{entry.title}
+ +

{renderHTML(entry.body)}

+ +

+
+ )); + } + + return ( +
+ +
+
+
+ {showArticles} +
+
+
+
+
+
+ ); + } +} +const mapStateToProps= state =>({ + entry:state.entries, +}) + +export default connect( + mapStateToProps, + { + fetchEntries + } + )(GetEntries); diff --git a/src/component/Main.jsx b/src/component/Main.jsx new file mode 100644 index 0000000..75650f2 --- /dev/null +++ b/src/component/Main.jsx @@ -0,0 +1,86 @@ +import React, { Component } from 'react'; +import {connect} from 'react-redux'; +import Navbar from './Navbar'; +import Footer from './Footer'; +import EntryForm from './EntryForm'; +import Menu from './menu'; +import { + CreateEntries, UpdateEntries + } from '../actions/AuthAction'; + +class Main extends Component { + state = { + title:"", + body:"" + } + onchange=(e)=>{ + this.setState({ + [e.target.name]:e.target.value + }); + } + handleChange=(text, medium)=> { + this.setState({body: text}); + } + + onhandleSubmit=(event)=>{ + event.preventDefault() + const data={ + title:this.state.title, + body:this.state.body, + } + if(this.props.action_to_main === "create_entry"){ + this.props.CreateEntries(data); + }else if(this.props.action_to_main === "update_entry"){ + this.props.UpdateEntries(data, this.props.id); + } + this.componentDidUpdate=()=>{ + const { history } = this.props; + history.push("/allEntries"); + } + } + componentDidUpdate(prevProps){ + if(this.props.title !== prevProps.title){ + this.setState({ + body:this.props.body, + title:this.props.title, + }) + } + } + + render() { + const status_code=this.props.entry.entry.status_code === 400 || this.props.entry.entry.status_code===409; + const message = this.props.entry.entry.message; + return ( +
+ +
+
+ + {status_code ? +
{message}
:"none"} +
+
+
+
+
+ ); + } +} +const mapStateToProps= state =>({ + entry:state.entries, +}) + +export default connect( + mapStateToProps, + { + CreateEntries, UpdateEntries + } + )(Main); diff --git a/src/component/Navbar.jsx b/src/component/Navbar.jsx new file mode 100644 index 0000000..195f917 --- /dev/null +++ b/src/component/Navbar.jsx @@ -0,0 +1,9 @@ +import React from 'react'; + +const Nabar = () => ( +
+
Keno
+
+
+); +export default Nabar; diff --git a/src/component/Notfound.jsx b/src/component/Notfound.jsx index 23c259c..7372c4b 100644 --- a/src/component/Notfound.jsx +++ b/src/component/Notfound.jsx @@ -1,9 +1,13 @@ import React from 'react'; +import Navbar from '../component/Navbar'; const notFound = () => ( -
+
+ +

PAGE NOT FOUND

+
); export default notFound; diff --git a/src/component/register.js b/src/component/Register.jsx similarity index 99% rename from src/component/register.js rename to src/component/Register.jsx index 21dfaf3..bf7273a 100644 --- a/src/component/register.js +++ b/src/component/Register.jsx @@ -100,4 +100,4 @@ export default connect( { signUpUser, loginUser, } - )(RegistrationForm); \ No newline at end of file + )(RegistrationForm); diff --git a/src/component/SingleEntry.jsx b/src/component/SingleEntry.jsx new file mode 100644 index 0000000..4b4fba6 --- /dev/null +++ b/src/component/SingleEntry.jsx @@ -0,0 +1,68 @@ +import React, { Component } from 'react'; +import {connect} from 'react-redux'; +import renderHTML from 'react-render-html'; +import Navbar from './Navbar' +import Footer from './Footer'; +import Menu from './menu'; +import { + singleEntry, + } from '../actions/AuthAction'; +class ViewEntry extends Component { + state = { + title:"", + body:"" + } + componentWillMount(){ + if (this.props.match.params.id) { + const id = this.props.match.params.id; + this.props.singleEntry(id) + } + } + goUpdate=(id)=>{ + const { history } = this.props; + history.push(`/entry/${id}/edit`);} + + render() { + const entry=this.props.entry.entry.result; + let showEntry; + let entry_id; + if(entry){ + entry_id = entry[0].id; + showEntry = entry.map(entry => ( +
+

{entry.title}


+
{renderHTML(entry.body)}
+
+ +
+ ));} + return ( +
+ < Navbar /> +
+
+
+
+
+
+
+
+ {showEntry} +
+
+
+ ); +} +} +const mapStateToProps= state =>({ + entry:state.entries, +}) + +export default connect( + mapStateToProps, + { + singleEntry + } + )(ViewEntry); diff --git a/src/component/UpdateEntry.jsx b/src/component/UpdateEntry.jsx new file mode 100644 index 0000000..2dd0c00 --- /dev/null +++ b/src/component/UpdateEntry.jsx @@ -0,0 +1,44 @@ +import React, { Component } from 'react'; +import { connect } from 'react-redux'; +import Main from './Main'; +import { + singleEntry, +} from '../actions/AuthAction'; + +class UpdateEntry extends Component { + componentWillMount() { + this.props.singleEntry(this.props.match.params.id); + } + + render() { + if (this.props.entry.result) { + const data = this.props.entry.result[0]; + this.title = data.title; + this.body = data.body; + } + return ( +
+
+
+ ); + } +} + +const mapStateToProps = state => ({ + entry: state.entries.entry, +}); + +export default connect( + mapStateToProps, + { + singleEntry, + }, +)(UpdateEntry); diff --git a/src/component/footer.js b/src/component/footer.js deleted file mode 100644 index 502fcd4..0000000 --- a/src/component/footer.js +++ /dev/null @@ -1,13 +0,0 @@ -import React, { Component } from 'react'; -class Footer extends Component { - state = { } - render() { - return ( - - ); - } -} - -export default Footer; \ No newline at end of file diff --git a/src/component/login.js b/src/component/login.jsx similarity index 89% rename from src/component/login.js rename to src/component/login.jsx index c8f51a9..548bd90 100644 --- a/src/component/login.js +++ b/src/component/login.jsx @@ -7,7 +7,7 @@ import { class LoginForm extends Component { state = { username:"", - loginpassword: "", + password: "", message:"", } @@ -25,6 +25,11 @@ class LoginForm extends Component { } this.props.loginUser(data) } + componentDidUpdate=()=>{ + if(this.props.user.user.token){ + const { history } = this.props; + history.push("/createEntry");} + } render() { if(this.props.user.user.token){ LoggedInUser(this.props.user.user.token,this.state.username) @@ -56,4 +61,4 @@ export default connect( { loginUser, } - )(LoginForm); \ No newline at end of file + )(LoginForm); diff --git a/src/component/menu.jsx b/src/component/menu.jsx new file mode 100644 index 0000000..6b61bb7 --- /dev/null +++ b/src/component/menu.jsx @@ -0,0 +1,11 @@ +import React from 'react'; +import { Link } from 'react-router-dom'; + +const Menu = () => ( +
+
CREATE AN ENTRY
+
ALL ENTRIES
+
PROFILE
+
+); +export default Menu; diff --git a/src/component/navbar.js b/src/component/navbar.js deleted file mode 100644 index c39f609..0000000 --- a/src/component/navbar.js +++ /dev/null @@ -1,13 +0,0 @@ -import React, { Component } from 'react'; -class Nabar extends Component { - state = { } - render() { - return ( -
- Keno
-
- ); - } -} - -export default Nabar; \ No newline at end of file diff --git a/src/container/landingpage.js b/src/container/landingpage.js deleted file mode 100644 index 16ec6fc..0000000 --- a/src/container/landingpage.js +++ /dev/null @@ -1,55 +0,0 @@ -import React, { Component } from 'react'; -import Navbar from '../component/navbar' -import Footer from '../component/footer' -import RegistrationForm from '../component/login' -import LoginForm from '../component/register' -class Landingpage extends Component { - state = { } - render() { - return ( -
- -
- -
-
-
-
WELCOME TO OUR ONLINE FREE DIARY
- KEEP ALL YOUR DAILY MEMORIES IN ONE PLACE
-
-
-

-
TO GET STARTED, REGISTER WITH US OR LOGIN
-
-
-
-
-
- -
-
- -
-
- -
-
-
-
-
-
-
-
-
- ); - } -} - -export default Landingpage; \ No newline at end of file diff --git a/src/container/landingpage.jsx b/src/container/landingpage.jsx new file mode 100644 index 0000000..fc29c4b --- /dev/null +++ b/src/container/landingpage.jsx @@ -0,0 +1,55 @@ +import React from 'react'; +import Navbar from '../component/Navbar'; +import Footer from '../component/Footer'; +import RegistrationForm from '../component/Register'; +import LoginForm from '../component/login'; + +const Landingpage = props => ( +
+ +
+ +
+
+
+
+ WELCOME TO OUR ONLINE FREE DIARY +
+ KEEP ALL YOUR DAILY MEMORIES IN ONE PLACE +
+
+
+
+
+
TO GET STARTED, REGISTER WITH US OR LOGIN
+
+
+
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+
+
+
+); + +export default Landingpage; diff --git a/src/index.css b/src/index.css index 42953d5..8171241 100644 --- a/src/index.css +++ b/src/index.css @@ -33,7 +33,8 @@ margin-bottom:10px; font-weight: bold; } .landing-row{ - height:60vh; + min-height:60vh; + max-height:auto; } .error{ margin-top:15px; @@ -47,4 +48,55 @@ margin-bottom:10px; text-align:center; margin-top:100px; } +*[contenteditable=true] { + padding: 5px 9px; + color:black; + height:100%; + border-radius: 4px; + outline: 0; +} +.entry_row{ + text-align:center !important; + margin-bottom:20px; + color:white; + font-size:25px; + } +.truncate *{ + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} +.title{ + font-weight:bold; + font-size:20px; +} +.entry_footer{ + font-size:15px; + font-weight: 500; +} +.entry_body{ + font-weight: 100; +} +.artcle_card{ + background-color:#D3D3D3; +} +.scroll{ + width:100%; + height:800px; + margin-bottom:30px; + border-radius:5px; + overflow:auto; +} +.word_wrap{ + word-wrap: break-word; +} +.links a{ + color: white; + border:2px solid white; + border-radius:5px; + padding:10px; +} +.links :hover{ + text-decoration:none; +} \ No newline at end of file diff --git a/src/index.js b/src/index.js index ca5efa8..f36b57a 100644 --- a/src/index.js +++ b/src/index.js @@ -8,4 +8,7 @@ import Popper from 'popper.js'; import './index.css'; import App from './App'; -ReactDOM.render(, document.getElementById('root')); \ No newline at end of file +ReactDOM.render( + , + document.getElementById('root') || document.createElement('div'), + ); \ No newline at end of file diff --git a/src/reducers/EntryReducer.js b/src/reducers/EntryReducer.js new file mode 100644 index 0000000..46d5310 --- /dev/null +++ b/src/reducers/EntryReducer.js @@ -0,0 +1,23 @@ +import { + CREATE_ENTRY, FETCH_ENTRIES, SINGLE_ENTRY, UPDATE_ENTRY, +} from '../actions/ActionTypes'; + +const initialState = { + entry: [], + entries: [], +}; +const entryReducer = (state = initialState, action) => { + switch (action.type) { + case CREATE_ENTRY: + return { ...state, entry: action.payload }; + case FETCH_ENTRIES: + return { ...state, entries: action.payload }; + case SINGLE_ENTRY: + return { ...state, entry: action.payload }; + case UPDATE_ENTRY: + return { ...state, entry: action.payload }; + default: + return state; + } +}; +export default entryReducer; diff --git a/src/reducers/index.jsx b/src/reducers/index.jsx index f3d117a..f284761 100644 --- a/src/reducers/index.jsx +++ b/src/reducers/index.jsx @@ -1,6 +1,8 @@ import { combineReducers } from 'redux'; import authReducer from './AuthReducer'; +import entryReducer from './EntryReducer'; export default combineReducers({ users: authReducer, + entries: entryReducer, }); diff --git a/src/App.test.js b/src/tests/App.test.js similarity index 89% rename from src/App.test.js rename to src/tests/App.test.js index a754b20..823bacb 100644 --- a/src/App.test.js +++ b/src/tests/App.test.js @@ -1,6 +1,6 @@ import React from 'react'; import ReactDOM from 'react-dom'; -import App from './App'; +import App from '../App'; it('renders without crashing', () => { const div = document.createElement('div'); diff --git a/src/tests/Entry.test.jsx b/src/tests/Entry.test.jsx new file mode 100644 index 0000000..54f884b --- /dev/null +++ b/src/tests/Entry.test.jsx @@ -0,0 +1,85 @@ +import Enzyme, { shallow, mount } from 'enzyme'; +import Adapter from 'enzyme-adapter-react-16'; +import React from 'react'; +import { Provider } from 'react-redux'; +import { BrowserRouter as Router } from 'react-router-dom'; +import configureMockStore from 'redux-mock-store'; +import CreateEntries from '../component/CreateEntry'; +import RegistrationForm from '../component/Register'; +import LoginForm from '../component/login'; +import Main from '../component/Main'; +import UpdateEntry from '../component/UpdateEntry'; +import GetEntries from '../component/GetEntries'; +import ViewEntry from '../component/SingleEntry'; +import store from '../store'; + + +Enzyme.configure({ adapter: new Adapter() }); + +describe('entries components', () => { + const mockStore = configureMockStore(); + beforeEach(() => { + mockStore({}); + }); + const getEvent = () => ({ + preventDefault: jest.fn(), + }); + + it('should test get all entries without crashing', () => { + mount(); + }); + it('should test create entry without crashing', () => { + mount(); + }); + it('should test update entry without crashing', () => { + const props = { + entry: { + results: { title: 'man' }, + }, + }; + mount(); + }); + it('should test view entry without crashing', () => { + mount(); + }); + it('should test register user without crashing', () => { + const props = { + user: { + user: { token: 'kjbhvgftryfuv' }, + }, + loginUser: jest.fn(), + LoggedInUser: jest.fn(), + }; + const component = shallow().dive().instance(); + component.change({ target: { value: 'firstname' } }); + component.handleSubmit({ preventDefault() {} }); + }); + it('should test login user without crashing', () => { + const component = shallow().dive().instance(); + component.Change({ target: { value: 'firstname' } }); + component.handleSubmit({ preventDefault() {} }); + }); + it('should test main page create entry without crashing', () => { + const props = { + action_to_main: 'create_entry', + id: 1, + CreateEntries: jest.fn(), + UpdateEntries: jest.fn(), + }; + const component = shallow(
).dive().instance(); + component.onchange({ target: { value: 'title' } }); + component.handleChange({ target: { value: 'body' } }); + component.onhandleSubmit({ preventDefault() {} }); + }); + it('should test main page update entry without crashing', () => { + const props = { + action_to_main: 'update_entry', + id: 2, + UpdateEntries: jest.fn(), + }; + const component = shallow(
).dive().instance(); + component.onchange({ target: { value: 'title1' } }); + component.handleChange({ target: { value: 'body1' } }); + component.onhandleSubmit({ preventDefault() {} }); + }); +}); diff --git a/src/tests/EntryReducers.test.jsx b/src/tests/EntryReducers.test.jsx new file mode 100644 index 0000000..a165d67 --- /dev/null +++ b/src/tests/EntryReducers.test.jsx @@ -0,0 +1,54 @@ +import { + SIGNUP, LOGIN, CREATE_ENTRY, FETCH_ENTRIES, SINGLE_ENTRY, UPDATE_ENTRY, +} from '../actions/ActionTypes'; +import entryReducer from '../reducers/EntryReducer'; +import authReducer from '../reducers/AuthReducer'; + +it('sign up entry reducer ', () => { + authReducer( + {}, + { + type: SIGNUP, + }, + ); +}); +it('login entry reducer', () => { + authReducer( + {}, + { + type: LOGIN, + }, + ); +}); +it('create entry reducer', () => { + entryReducer( + {}, + { + type: CREATE_ENTRY, + }, + ); +}); +it('fetch entries reducer', () => { + entryReducer( + {}, + { + type: FETCH_ENTRIES, + }, + ); +}); +it('fetch single entry reducer', () => { + entryReducer( + {}, + { + type: SINGLE_ENTRY, + }, + ); +}); +it('update entry reducer', () => { + entryReducer( + {}, + { + type: UPDATE_ENTRY, + }, + ); +}); diff --git a/src/tests/functions.test.jsx b/src/tests/functions.test.jsx new file mode 100644 index 0000000..54371d6 --- /dev/null +++ b/src/tests/functions.test.jsx @@ -0,0 +1,6 @@ +import LoggedInUser from '../common/getToken'; + +test('set token in local storage', () => { + expect(LoggedInUser('token', 'username')); +}); + diff --git a/src/tests/index.test.jsx b/src/tests/index.test.jsx new file mode 100644 index 0000000..e0ba1a3 --- /dev/null +++ b/src/tests/index.test.jsx @@ -0,0 +1,9 @@ +import Index from '../index'; + +it('renders without crashing', () => { + expect( + JSON.stringify( + Object.assign({}, Index, { _reactInternalInstance: 'censored' }), + ), + ) +});