How to use objectValues method in jest-extended

Best JavaScript code snippet using jest-extended

AppLogic.js

Source:AppLogic.js Github

copy

Full Screen

1import React, { useState, useEffect } from "react";2import { Switch, Route, useHistory } from "react-router-dom";3import AuthenticationMainPage from "./MainAppPages/AuthenticationMainPage.js";4import DataStoreMainPage from "./MainAppPages/DataStoreMainPage.js";5import { Auth } from "aws-amplify";6import { DataStore } from "aws-amplify";7import { CourseDetails } from "./Models";8import * as EmailValidator from "email-validator";9import { useUserFormFields } from "./Other/customHook.js";10export default function AppLogic() {11 /** ----------------------------------------------------------- AUTHENTICATION LOGIC START ------------------------------------------------------ **/12 const [authenticationFlow, setAuthenticationFlow] = useState("SignIn");13 let history = useHistory();14 const [userAttributes, setUserAttributes] = useUserFormFields({15 userEmail: "",16 userPassword: "",17 userCode: "",18 firstName: "",19 lastName: "",20 });21 const [showValidation, setShowValidation] = useState({22 userEmailValidation: false,23 userPasswordValidation: false,24 userCodeValidation: false,25 firstNameValidation: false,26 lastNameValidation: false,27 });28 const [showValidationText, setShowValidationText] = useState({29 userEmailValidationText: "",30 userPasswordValidationText: "",31 userCodeValidationText: "",32 firstNameValidationText: "",33 lastNameValidationText: "",34 });35 const [showMessage, setShowMessage] = useState(false);36 const [showMessageText, setShowMessageText] = useState("");37 const [startLoading, setStartLoading] = useState(false);38 const [emailCheck, setEmailCheck] = useState("");39 const [showPassword, setShowPassword] = useState(false);40 const {41 userEmail,42 userPassword,43 userCode,44 firstName,45 lastName,46 } = userAttributes;47 const handleShowPassword = () => {48 setShowPassword(!showPassword);49 };50 const handleMouseDownPassword = (event) => {51 event.preventDefault();52 };53 const ClearFields = () => {54 userAttributes.userEmail = "";55 userAttributes.userPassword = "";56 userAttributes.userCode = "";57 userAttributes.firstName = "";58 userAttributes.lastName = "";59 };60 useEffect(() => {61 if (userEmail.length >= 1) {62 setShowValidation((objectValues) => ({63 ...objectValues,64 userEmailValidation: false,65 }));66 setShowValidationText((objectValues) => ({67 ...objectValues,68 userEmailValidationText: "",69 }));70 }71 if (userPassword.length >= 1) {72 setShowValidation((objectValues) => ({73 ...objectValues,74 userPasswordValidation: false,75 }));76 setShowValidationText((objectValues) => ({77 ...objectValues,78 userPasswordValidationText: "",79 }));80 }81 if (userCode.length >= 1) {82 setShowValidation((objectValues) => ({83 ...objectValues,84 userCodeValidation: false,85 }));86 setShowValidationText((objectValues) => ({87 ...objectValues,88 userCodeValidationText: "",89 }));90 }91 if (firstName.length >= 1) {92 setShowValidation((objectValues) => ({93 ...objectValues,94 firstNameValidation: false,95 }));96 setShowValidationText((objectValues) => ({97 ...objectValues,98 firstNameValidationText: "",99 }));100 }101 if (lastName.length >= 1) {102 setShowValidation((objectValues) => ({103 ...objectValues,104 lastNameValidation: false,105 }));106 setShowValidationText((objectValues) => ({107 ...objectValues,108 lastNameValidationText: "",109 }));110 }111 if (EmailValidator.validate(userEmail)) {112 setEmailCheck("correctFormat");113 } else if (userEmail === "") {114 setEmailCheck("nonFormat");115 } else {116 setEmailCheck("incorrectFormat");117 }118 }, [userEmail, userPassword, userCode, firstName, lastName]);119 const handleSignIn = async (event) => {120 event.preventDefault();121 if (122 userEmail === "" ||123 userPassword === "" ||124 emailCheck === "incorrectFormat"125 ) {126 if (userEmail === "") {127 setShowValidation((objectValues) => ({128 ...objectValues,129 userEmailValidation: true,130 }));131 setShowValidationText((objectValues) => ({132 ...objectValues,133 userEmailValidationText: "Email Is Empty!",134 }));135 }136 if (emailCheck === "incorrectFormat") {137 setShowValidation((objectValues) => ({138 ...objectValues,139 userEmailValidation: true,140 }));141 setShowValidationText((objectValues) => ({142 ...objectValues,143 userEmailValidationText: "Email Is Not Valid!",144 }));145 }146 if (userPassword === "") {147 setShowValidation((objectValues) => ({148 ...objectValues,149 userPasswordValidation: true,150 }));151 setShowValidationText((objectValues) => ({152 ...objectValues,153 userPasswordValidationText: "Password Is Empty!",154 }));155 }156 } else {157 let outputText = "";158 // You can pass an object which has the username, password and validationData which is sent to a PreAuthentication Lambda trigger159 await Auth.signIn({ username: userEmail, password: userPassword })160 .then(() => ClearFields())161 .then(() => setStartLoading(true))162 .then(() =>163 setTimeout(() => {164 history.push("/user-session");165 }, 3500)166 )167 .then(() => setStartLoading(false))168 .catch((err) => (outputText = err.message));169 if (outputText !== "" || typeof outputText === "undefined") {170 setShowMessage(true);171 setShowMessageText(outputText);172 }173 setTimeout(() => {174 setShowMessage(false);175 }, 3000);176 }177 };178 const handleRequestCode = async (event) => {179 event.preventDefault();180 if (userEmail === "" || emailCheck === "incorrectFormat") {181 if (userEmail === "") {182 setShowValidation((objectValues) => ({183 ...objectValues,184 userEmailValidation: true,185 }));186 setShowValidationText((objectValues) => ({187 ...objectValues,188 userEmailValidationText: "Email Is Empty!",189 }));190 }191 if (emailCheck === "incorrectFormat") {192 setShowValidation((objectValues) => ({193 ...objectValues,194 userEmailValidation: true,195 }));196 setShowValidationText((objectValues) => ({197 ...objectValues,198 userEmailValidationText: "Email Is Not Valid!",199 }));200 }201 } else {202 let outputText = "";203 await Auth.forgotPassword(userEmail)204 .then((data) => (outputText = data.CodeDeliveryDetails.AttributeName))205 .then(() =>206 setTimeout(() => {207 setAuthenticationFlow("ResetPassword");208 }, 3500)209 )210 .catch((err) => (outputText = err.message));211 if (outputText === "email") {212 setShowMessage(true);213 setShowMessageText("Code is sent! Check your email.");214 } else {215 setShowMessage(true);216 setShowMessageText(outputText);217 }218 setTimeout(() => {219 setShowMessage(false);220 }, 3000);221 }222 };223 const handleResetPassword = async (event) => {224 event.preventDefault();225 if (userCode === "" || userPassword === "") {226 if (userCode === "") {227 setShowValidation((objectValues) => ({228 ...objectValues,229 userCodeValidation: true,230 }));231 setShowValidationText((objectValues) => ({232 ...objectValues,233 userCodeValidationText: "User Code Is Empty!",234 }));235 }236 if (userPassword === "") {237 setShowValidation((objectValues) => ({238 ...objectValues,239 userPasswordValidation: true,240 }));241 setShowValidationText((objectValues) => ({242 ...objectValues,243 userPasswordValidationText: "Password Is Empty!",244 }));245 }246 } else {247 let outputText = "";248 await Auth.forgotPasswordSubmit(userEmail, userCode, userPassword)249 .then((data) => (outputText = data))250 .catch((err) => (outputText = err.message));251 if (outputText === "undefined" || typeof outputText === "undefined") {252 userAttributes.userCode = "";253 userAttributes.userPassword = "";254 setShowMessage(true);255 setShowMessageText("Password Reseted! Go Back To Sign In");256 } else {257 setShowMessage(true);258 setShowMessageText(outputText);259 }260 setTimeout(() => {261 setShowMessage(false);262 }, 3000);263 }264 };265 const handleSignUp = async (event) => {266 event.preventDefault();267 if (268 firstName === "" ||269 lastName === "" ||270 userEmail === "" ||271 emailCheck === "incorrectFormat" ||272 userPassword === ""273 ) {274 if (firstName === "") {275 setShowValidation((objectValues) => ({276 ...objectValues,277 firstNameValidation: true,278 }));279 setShowValidationText((objectValues) => ({280 ...objectValues,281 firstNameValidationText: "First Name Is Empty!",282 }));283 }284 if (lastName === "") {285 setShowValidation((objectValues) => ({286 ...objectValues,287 lastNameValidation: true,288 }));289 setShowValidationText((objectValues) => ({290 ...objectValues,291 lastNameValidationText: "Last Name Is Empty!",292 }));293 }294 if (userEmail === "") {295 setShowValidation((objectValues) => ({296 ...objectValues,297 userEmailValidation: true,298 }));299 setShowValidationText((objectValues) => ({300 ...objectValues,301 userEmailValidationText: "Email Is Empty!",302 }));303 }304 if (emailCheck === "incorrectFormat") {305 setShowValidation((objectValues) => ({306 ...objectValues,307 userEmailValidation: true,308 }));309 setShowValidationText((objectValues) => ({310 ...objectValues,311 userEmailValidationText: "Email Is Not Valid!",312 }));313 }314 if (userPassword === "") {315 setShowValidation((objectValues) => ({316 ...objectValues,317 userPasswordValidation: true,318 }));319 setShowValidationText((objectValues) => ({320 ...objectValues,321 userPasswordValidationText: "Password Is Empty!",322 }));323 }324 } else {325 let outputText = "";326 await Auth.signUp({327 username: userEmail,328 password: userPassword,329 attributes: {330 given_name: firstName,331 family_name: lastName,332 email: userEmail,333 },334 })335 .then((data) => (outputText = data.codeDeliveryDetails.AttributeName))336 .then(() =>337 setTimeout(() => {338 setAuthenticationFlow("Verify");339 }, 3500)340 )341 .catch((err) => (outputText = err.message));342 if (outputText === "email") {343 setShowMessage(true);344 setShowMessageText("Account with " + userEmail + " is created!");345 } else {346 setShowMessage(true);347 setShowMessageText(outputText);348 }349 setTimeout(() => {350 setShowMessage(false);351 }, 3000);352 }353 };354 const handleVerifyCode = async (event) => {355 event.preventDefault();356 if (userCode === "") {357 setShowValidation((objectValues) => ({358 ...objectValues,359 userCodeValidation: true,360 }));361 setShowValidationText((objectValues) => ({362 ...objectValues,363 userCodeValidationText: "User Code Is Empty!",364 }));365 } else {366 let outputText = "";367 await Auth.confirmSignUp(userEmail, userCode)368 .then((data) => (outputText = data))369 .catch((err) => (outputText = err.message));370 if (outputText === "SUCCESS") {371 userAttributes.userCode = "";372 setShowMessage(true);373 setShowMessageText("Account with " + userEmail + " is verified!");374 } else {375 setShowMessage(true);376 setShowMessageText(outputText);377 }378 setTimeout(() => {379 setShowMessage(false);380 }, 3000);381 }382 };383 const handleSignOut = async () => {384 await Auth.signOut()385 .then(() => setStartLoading(true))386 .then(() =>387 setTimeout(() => {388 history.push("/");389 }, 3500)390 )391 .then(() => setStartLoading(false))392 .catch((err) => console.log(err.message));393 userAttributes.userEmail = "";394 userAttributes.userPassword = "";395 DataStore.clear();396 };397 const showSignUp = () => {398 setAuthenticationFlow("SignUp");399 userAttributes.userEmail = "";400 userAttributes.userPassword = "";401 userAttributes.firstName = "";402 userAttributes.lastName = "";403 showValidation.userEmailValidation = false;404 showValidationText.userEmailValidationText = "";405 showValidation.userPasswordValidation = false;406 showValidationText.userPasswordValidationText = "";407 showValidation.firstNameValidation = false;408 showValidationText.firstNameValidationText = "";409 showValidation.lastNameValidation = false;410 showValidationText.lastNameValidationText = "";411 };412 const showSignIn = () => {413 setAuthenticationFlow("SignIn");414 userAttributes.userEmail = "";415 userAttributes.userPassword = "";416 userAttributes.userCode = "";417 showValidation.userEmailValidation = false;418 showValidationText.userEmailValidationText = "";419 showValidation.userPasswordValidation = false;420 showValidationText.userPasswordValidationText = "";421 showValidation.userCodeValidation = false;422 showValidation.userCodeValidationText = "";423 };424 const showResetCode = () => {425 setAuthenticationFlow("ResetCode");426 userAttributes.userEmail = "";427 userAttributes.userPassword = "";428 showValidation.userEmailValidation = false;429 showValidationText.userEmailValidationText = "";430 showValidation.userPasswordValidation = false;431 showValidationText.userPasswordValidationText = "";432 showValidation.userCodeValidation = false;433 showValidationText.userCodeValidationText = "";434 };435 /** ----------------------------------------------------------- AUTHENTICATION LOGIC END -------------------------------------------------------- **/436 /** --------------------------------------------------------------- DATA STORE LOGIC START ------------------------------------------------------ **/437 const [anchorEl, setAnchorEl] = useState(null);438 const openAnchorEl = Boolean(anchorEl);439 const [openProfile, setOpenProfile] = useState(false);440 const [courseDetails, setCourseDetails] = useState({441 courseName: "",442 courseGrade: "",443 courseSemester: "",444 courseRating: "",445 });446 const [showCourseValidation, setShowCourseValidation] = useState({447 courseNameValidation: false,448 courseGradeValidation: false,449 courseSemesterValidation: false,450 courseRatingValidation: false,451 });452 const [showCourseValidationText, setShowCourseValidationText] = useState({453 courseNameValidationText: "",454 courseGradeValidationText: "",455 courseSemesterValidationText: "",456 courseRatingValidationText: "",457 });458 const [courseCheck, setCourseCheck] = useState(false);459 const [showCourseDetails, setShowCourseDetails] = useState([]);460 const [showLoading, setShowLoading] = useState(true);461 const [firstInitial, setFirstInitial] = useState("");462 const [secondInitial, setSecondInitial] = useState("");463 const [maximumNum, setMaximumNum] = useState(0);464 const [minimumNum, setMinimumNum] = useState(0);465 const [averageNum, setAverageNum] = useState(0);466 const [maximumList, setMaximumList] = useState([]);467 const [minimumList, setMinimumList] = useState([]);468 const [feedbackColorGreen, setFeedbackColorGreen] = useState(false);469 const [feedbackColorOrange, setFeedbackColorOrange] = useState(false);470 const [feedbackColorRed, setFeedbackColorRed] = useState(false);471 const {472 courseName,473 courseGrade,474 courseSemester,475 courseRating,476 } = courseDetails;477 const handleMenu = (event) => {478 setAnchorEl(event.currentTarget);479 };480 const handleClose = () => {481 setAnchorEl(null);482 };483 const handleOpenProfile = async () => {484 setOpenProfile(true);485 const { attributes } = await Auth.currentAuthenticatedUser();486 let firstName = attributes.given_name.charAt(0);487 let lastName = attributes.family_name.charAt(0);488 setFirstInitial(firstName);489 setSecondInitial(lastName);490 setAnchorEl(null);491 };492 const handleCloseProfile = () => {493 setOpenProfile(false);494 setFeedbackColorGreen(false);495 setFeedbackColorOrange(false);496 setFeedbackColorRed(false);497 };498 useEffect(() => {499 if (courseName.length >= 1) {500 setShowCourseValidation((objectValues) => ({501 ...objectValues,502 courseNameValidation: false,503 }));504 setShowCourseValidationText((objectValues) => ({505 ...objectValues,506 courseNameValidationText: "",507 }));508 }509 if (courseGrade.length >= 1) {510 setShowCourseValidation((objectValues) => ({511 ...objectValues,512 courseGradeValidation: false,513 }));514 setShowCourseValidationText((objectValues) => ({515 ...objectValues,516 courseGradeValidationText: "",517 }));518 }519 if (courseGrade !== "100" && courseGrade.length >= 3) {520 setShowCourseValidation((objectValues) => ({521 ...objectValues,522 courseGradeValidation: true,523 }));524 setShowCourseValidationText((objectValues) => ({525 ...objectValues,526 courseGradeValidationText: "Can Not Enter Bigger Than 100!",527 }));528 }529 if (courseGrade.length === 0) {530 setShowCourseValidation((objectValues) => ({531 ...objectValues,532 courseGradeValidation: false,533 }));534 setShowCourseValidationText((objectValues) => ({535 ...objectValues,536 courseGradeValidationText: "",537 }));538 }539 if (Math.sign(courseGrade) === -1) {540 setShowCourseValidation((objectValues) => ({541 ...objectValues,542 courseGradeValidation: true,543 }));544 setShowCourseValidationText((objectValues) => ({545 ...objectValues,546 courseGradeValidationText: "Can Not Enter Smaller Than 0!",547 }));548 }549 if (courseSemester.length >= 1) {550 setShowCourseValidation((objectValues) => ({551 ...objectValues,552 courseSemesterValidation: false,553 }));554 setShowCourseValidationText((objectValues) => ({555 ...objectValues,556 courseSemesterValidationText: "",557 }));558 }559 if (courseRating.length >= 1) {560 setShowCourseValidation((objectValues) => ({561 ...objectValues,562 courseRatingValidation: false,563 }));564 setShowCourseValidationText((objectValues) => ({565 ...objectValues,566 courseRatingValidationText: "",567 }));568 }569 }, [courseName, courseGrade, courseSemester, courseRating]);570 const handleCourseName = (event) => {571 setCourseDetails((objectValues) => ({572 ...objectValues,573 courseName: event.target.value,574 }));575 };576 const handleCourseGrade = (event) => {577 setCourseDetails((objectValues) => ({578 ...objectValues,579 courseGrade: event.target.value,580 }));581 };582 const handleCourseSemester = (event) => {583 setCourseDetails((objectValues) => ({584 ...objectValues,585 courseSemester: event.target.value,586 }));587 };588 const handleCourseRating = (event) => {589 setCourseDetails((objectValues) => ({590 ...objectValues,591 courseRating: event.target.value,592 }));593 };594 const handleAddCourse = async (event) => {595 event.preventDefault();596 if (597 courseName === "" ||598 courseGrade === "" ||599 (courseGrade !== "100" && courseGrade.length >= 3) ||600 Math.sign(courseGrade) === -1 ||601 courseSemester === "" ||602 courseRating === "" ||603 courseCheck === true604 ) {605 if (courseName === "") {606 setShowCourseValidation((objectValues) => ({607 ...objectValues,608 courseNameValidation: true,609 }));610 setShowCourseValidationText((objectValues) => ({611 ...objectValues,612 courseNameValidationText: "Course Name Is Empty!",613 }));614 }615 if (courseGrade === "") {616 setShowCourseValidation((objectValues) => ({617 ...objectValues,618 courseGradeValidation: true,619 }));620 setShowCourseValidationText((objectValues) => ({621 ...objectValues,622 courseGradeValidationText: "Course Grade Is Empty!",623 }));624 }625 if (courseGrade !== "100" && courseGrade.length >= 3) {626 setShowCourseValidation((objectValues) => ({627 ...objectValues,628 courseGradeValidation: true,629 }));630 setShowCourseValidationText((objectValues) => ({631 ...objectValues,632 courseGradeValidationText: "Can Not Enter Bigger Than 100!",633 }));634 }635 if (Math.sign(courseGrade) === -1) {636 setShowCourseValidation((objectValues) => ({637 ...objectValues,638 courseGradeValidation: true,639 }));640 setShowCourseValidationText((objectValues) => ({641 ...objectValues,642 courseGradeValidationText: "Can Not Enter Smaller Than 0!",643 }));644 }645 if (courseSemester === "") {646 setShowCourseValidation((objectValues) => ({647 ...objectValues,648 courseSemesterValidation: true,649 }));650 setShowCourseValidationText((objectValues) => ({651 ...objectValues,652 courseSemesterValidationText: "Select Course Semester!",653 }));654 }655 if (courseRating === "") {656 setShowCourseValidation((objectValues) => ({657 ...objectValues,658 courseRatingValidation: true,659 }));660 setShowCourseValidationText((objectValues) => ({661 ...objectValues,662 courseRatingValidationText: "Select Course Rating!",663 }));664 }665 if (courseCheck === true) {666 setShowCourseValidation((objectValues) => ({667 ...objectValues,668 courseNameValidation: true,669 }));670 setShowCourseValidationText((objectValues) => ({671 ...objectValues,672 courseNameValidationText: "Course Name Is Same!",673 }));674 }675 } else {676 try {677 await DataStore.save(678 new CourseDetails({679 courseName: courseName,680 courseGrade: courseGrade,681 courseSemester: courseSemester,682 courseRating: courseRating,683 })684 )685 .then(() => setShowMessage(true))686 .then(() => setShowMessageText(courseName + " is added!"));687 setTimeout(() => {688 setShowMessage(false);689 }, 3000);690 } catch (error) {691 setShowMessage(true);692 setShowMessageText(error);693 setTimeout(() => {694 setShowMessage(false);695 }, 3000);696 }697 setCourseDetails((objectValues) => ({698 ...objectValues,699 courseName: "",700 }));701 setCourseDetails((objectValues) => ({702 ...objectValues,703 courseGrade: "",704 }));705 setCourseDetails((objectValues) => ({706 ...objectValues,707 courseSemester: "",708 }));709 setCourseDetails((objectValues) => ({710 ...objectValues,711 courseRating: "",712 }));713 }714 };715 const handleRead = async () => {716 try {717 await DataStore.query(CourseDetails)718 .then((courseDetails) => setShowCourseDetails(courseDetails))719 .then(() => setShowLoading(false));720 // console.log("Posts retrieved successfully!", JSON.stringify(CourseDetails, null, 2));721 } catch (error) {722 console.log("Error retrieving posts", error);723 }724 };725 useEffect(() => {726 handleRead();727 showCourseDetails.forEach((courseDetails, index) => {728 if (courseDetails.courseName === courseName) {729 setCourseCheck(true);730 setShowCourseValidation((objectValues) => ({731 ...objectValues,732 courseNameValidation: true,733 }));734 setShowCourseValidationText((objectValues) => ({735 ...objectValues,736 courseNameValidationText: "Course Name Is Same!",737 }));738 } else {739 setCourseCheck(false);740 }741 });742 }, [showCourseDetails, courseName]);743 let maxNum = Math.max.apply(744 Math,745 showCourseDetails.map((course) => course.courseGrade)746 );747 if (maxNum === -Infinity) maxNum = 0;748 let minNum = Math.min.apply(749 Math,750 showCourseDetails.map((course) => course.courseGrade)751 );752 if (minNum === Infinity) minNum = 0;753 let avgNum = 0;754 let sum = 0;755 let size = 0;756 size = showCourseDetails.length;757 sum = showCourseDetails.reduce(758 (sum, course) => sum + parseInt(course.courseGrade),759 0760 );761 avgNum = Math.round(sum / size);762 if (isNaN(avgNum)) {763 avgNum = 0;764 }765 let maxList = [];766 let minList = [];767 maxList = showCourseDetails768 .sort((a, b) => {769 return b.courseGrade - a.courseGrade;770 })771 .slice(0, 3);772 minList = showCourseDetails773 .sort((a, b) => {774 return a.courseGrade - b.courseGrade;775 })776 .slice(0, 3);777 useEffect(() => {778 setMaximumNum(maxNum);779 setMinimumNum(minNum);780 setAverageNum(avgNum);781 setMaximumList(maxList);782 setMinimumList(minList);783 if (avgNum >= 1 && avgNum <= 50) {784 setFeedbackColorGreen(false);785 setFeedbackColorOrange(false);786 setTimeout(() => {787 setFeedbackColorRed(true);788 }, avgNum * 70);789 } else if (avgNum >= 51 && avgNum <= 80) {790 setFeedbackColorGreen(false);791 setFeedbackColorRed(false);792 setTimeout(() => {793 setFeedbackColorOrange(true);794 }, avgNum * 70);795 } else if (avgNum >= 81 && avgNum <= 100) {796 setFeedbackColorOrange(false);797 setFeedbackColorRed(false);798 setTimeout(() => {799 setFeedbackColorGreen(true);800 }, avgNum * 70);801 } else {802 setFeedbackColorGreen(false);803 setFeedbackColorOrange(false);804 setFeedbackColorRed(false);805 }806 }, [807 maxNum,808 minNum,809 avgNum,810 feedbackColorGreen,811 feedbackColorOrange,812 feedbackColorRed,813 ]);814 /** --------------------------------------------------------------- DATA STORE LOGIC END ------------------------------------------------------ **/815 return (816 <React.Fragment>817 <Switch>818 <Route819 exact820 path="/"821 render={(props) => (822 <AuthenticationMainPage823 {...props}824 authenticationFlow={authenticationFlow}825 showGrowEffect={true}826 startLoading={startLoading}827 userAttributes={userAttributes}828 setUserAttributes={setUserAttributes}829 showValidation={showValidation}830 showValidationText={showValidationText}831 handleSignUp={handleSignUp}832 handleVerifyCode={handleVerifyCode}833 handleSignIn={handleSignIn}834 handleRequestCode={handleRequestCode}835 handleResetPassword={handleResetPassword}836 showSignIn={showSignIn}837 showSignUp={showSignUp}838 showResetCode={showResetCode}839 emailCheck={emailCheck}840 showPassword={showPassword}841 handleShowPassword={handleShowPassword}842 handleMouseDownPassword={handleMouseDownPassword}843 showMessage={showMessage}844 showMessageText={showMessageText}845 />846 )}847 />848 <Route849 exact850 path="/user-session"851 render={(props) => (852 <DataStoreMainPage853 {...props}854 startLoading={startLoading}855 anchorEl={anchorEl}856 openAnchorEl={openAnchorEl}857 handleMenu={handleMenu}858 handleClose={handleClose}859 handleOpenProfile={handleOpenProfile}860 handleSignOut={handleSignOut}861 courseDetails={courseDetails}862 handleCourseName={handleCourseName}863 handleCourseGrade={handleCourseGrade}864 handleCourseSemester={handleCourseSemester}865 handleCourseRating={handleCourseRating}866 showCourseValidation={showCourseValidation}867 showCourseValidationText={showCourseValidationText}868 handleAddCourse={handleAddCourse}869 showCourseDetails={showCourseDetails}870 showLoading={showLoading}871 openProfile={openProfile}872 handleCloseProfile={handleCloseProfile}873 firstInitial={firstInitial}874 secondInitial={secondInitial}875 maximumNum={maximumNum}876 minimumNum={minimumNum}877 averageNum={averageNum}878 maximumList={maximumList}879 minimumList={minimumList}880 feedbackColorGreen={feedbackColorGreen}881 feedbackColorOrange={feedbackColorOrange}882 feedbackColorRed={feedbackColorRed}883 showMessage={showMessage}884 showMessageText={showMessageText}885 />886 )}887 />888 </Switch>889 </React.Fragment>890 );...

Full Screen

Full Screen

tables-detail.js

Source:tables-detail.js Github

copy

Full Screen

1/**2 * 数据库id3 * @type {null}4 */5var id = null;6/**7 * 表名称8 * @type {null}9 */10var tableName = null;11$(document).ready(function () {12 id = getUrlParam("id");13 tableName = getUrlParam("name");14 /**15 * 显示表详情16 */17 showTableDetail();18});19/**20 * 显示建表语句21 */22function showTableDetail() {23 var param = {24 'id': id,25 'name': tableName,26 };27 $.ajax({28 url: AppUrl + '/tables/detail',//跨域请求的URL29 data: JSON.stringify(param),30 type: "POST",31 dataType: "json",32 contentType: "application/json;charset=UTF-8",33 success: function (data) {34 console.log(data)35 $.each(data, function (name, item) {36 if (name == "content") {37 console.log("name:" + name)38 $.each(item, function (bjectName, objectValues) {39 console.log("bjectName:" + bjectName)40 if (bjectName == "createTable") {41 showCreateTable(objectValues);42 }43 if (bjectName == "tableColumns") {44 showTableColumns(objectValues);45 }46 if (bjectName == "tableIndex") {47 showTableIndex(objectValues);48 }49 altRows();50 });51 }52 });53 },54 error: function (reason) {55 console.log(reason)56 }57 });58}59/**60 * 显示表索引信息61 */62function showTableIndex(objectValues) {63 var itemData = "";64 $.each(objectValues, function (bjectName, objectValues) {65 itemData += "<tr>";66 itemData += "<td>" + objectValues.table + "</td>";67 itemData += "<td>" + objectValues.nonUnique + "</td>";68 itemData += "<td>" + objectValues.keyName + "</td>";69 itemData += "<td>" + objectValues.seqInIndex + "</td>";70 itemData += "<td>" + objectValues.columnName + "</td>";71 itemData += "<td>" + objectValues.collation + "</td>";72 itemData += "<td>" + objectValues.cardinality + "</td>";73 itemData += "<td>" + objectValues.subPart + "</td>";74 itemData += "<td>" + objectValues.packed + "</td>";75 itemData += "<td>" + objectValues.nullValue + "</td>";76 itemData += "<td>" + objectValues.indexType + "</td>";77 itemData += "<td>" + objectValues.comment + "</td>";78 itemData += "<td>" + objectValues.indexComment + "</td>";79 itemData += "<td>" + objectValues.visible + "</td>";80 itemData += "<td>" + objectValues.expression + "</td>";81 itemData += "</tr>";82 });83 $("#table-index").append(itemData);84}85/**86 * 显示表列的详情信息87 */88function showTableColumns(objectValues) {89 var itemData = "";90 $.each(objectValues, function (bjectName, objectValues) {91 itemData += "<tr>";92 itemData += "<td>" + objectValues.field + "</td>";93 itemData += "<td>" + objectValues.type + "</td>";94 itemData += "<td>" + objectValues.collation + "</td>";95 itemData += "<td>" + objectValues.nu + "</td>";96 itemData += "<td>" + objectValues.key + "</td>";97 itemData += "<td>" + objectValues.defau + "</td>";98 itemData += "<td>" + objectValues.extra + "</td>";99 itemData += "<td>" + objectValues.privileges + "</td>";100 itemData += "<td>" + objectValues.comment + "</td>";101 itemData += "</tr>";102 });103 $("#table-clumn table").append(itemData);104}105function altRows() {106 var rows = $("tr");107 for (i = 0; i < rows.length; i++) {108 if (i % 2 == 0) {109 rows[i].className = "evenrowcolor";110 } else {111 rows[i].className = "oddrowcolor";112 }113 }114}115/**116 * 显示创建表详情117 * @param objectValues118 */119function showCreateTable(objectValues) {120 $.each(objectValues, function (bjectName, objectValues) {121 console.log(bjectName,objectValues)122 $("#tableName").append(bjectName);123 // 加入代码符号124 objectValues = "```\r\n"+objectValues+"\r\n```\r\n";125 var markdownCode = marked(objectValues, {breaks: true});126 $("#tableCreate").html(markdownCode);127 // 重新渲染页面128 reHeightCode();129 });130}131/**132 * 解决问题:https://blog.csdn.net/qq_21383435/article/details/106886286133 * 代码渲染问题:134 * 循环每个代码段,然后获取代码,并且重新渲染135 * @param name136 * @returns {*}137 */138function reHeightCode() {139 $("pre code").each(function () {140 var code = $(this).text();141 var highCode = hljs.highlightAuto(code).value;142 $(this).html(highCode)143 });144}145/**146 * 获取地址栏 url 的参数信息147 * @param name148 * @returns {*}149 */150function getUrlParam(name) {151 var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象152 var r = window.location.search.substr(1).match(reg); //匹配目标参数153 if (r != null) return unescape(r[2]);154 return null; //返回参数值...

Full Screen

Full Screen

tables-list.js

Source:tables-list.js Github

copy

Full Screen

1var id = null;2$(document).ready(function () {3 id = getUrlParam("id");4 /**5 * 显示菜单6 */7 showTables();8});9/**10 * 显示菜单11 */12function showTables() {13 var param = {14 'id': id15 };16 $.ajax({17 url: AppUrl + '/tables/list',//跨域请求的URL18 data: JSON.stringify(param),19 type: "POST",20 dataType: "json",21 contentType: "application/json;charset=UTF-8",22 success: function (data) {23 console.log(data)24 $.each(data, function (name, item) {25 if (name == "content") {26 console.log("name:" + name)27 $.each(item, function (bjectName, objectValues) {28 console.log("bjectName:" + bjectName)29 if (bjectName == "tableDescsMain") {30 showTableDescsMain(objectValues);31 }32 if (bjectName == "tableDescsOther") {33 showTableDescsOther(objectValues);34 }35 altRows();36 });37 }38 });39 },40 error: function (reason) {41 console.log(reason)42 }43 });44}45function altRows() {46 var rows = $("tr");47 for (i = 0; i < rows.length; i++) {48 if (i % 2 == 0) {49 rows[i].className = "evenrowcolor";50 } else {51 rows[i].className = "oddrowcolor";52 }53 }54}55function showTableDescsOther(objectValues) {56 var itemData = "";57 $.each(objectValues, function (bjectName, objectValues) {58 itemData += "<tr>";59 itemData += "<td>" + objectValues.name + "</td>";60 itemData += "<td>" + objectValues.rowFormat + "</td>";61 itemData += "<td>" + objectValues.avgRowLength + "</td>";62 itemData += "<td>" + objectValues.dataLength + "</td>";63 itemData += "<td>" + objectValues.indexLength + "</td>";64 itemData += "<td>" + objectValues.dataFree + "</td>";65 itemData += "<td>" + objectValues.createTime + "</td>";66 itemData += "<td>" + objectValues.updateTime + "</td>";67 itemData += "<td>" + objectValues.checkTime + "</td>";68 itemData += "<td>" + objectValues.checksum + "</td>";69 itemData += "<td>" + objectValues.createOptions + "</td>";70 itemData += "<td>" + objectValues.comment + "</td>";71 itemData += "</tr>";72 });73 $(".tableDescsOther table").append(itemData);74}75/**76 * 表重要信息展示77 * @param objectValues78 */79function showTableDescsMain(objectValues) {80 var itemData = "";81 $.each(objectValues, function (bjectName, objectValues) {82 itemData += "<tr>";83 itemData += "<td>" + objectValues.name + "</td>";84 itemData += "<td>" + objectValues.engine + "</td>";85 itemData += "<td>" + objectValues.rows + "</td>";86 itemData += "<td>" + objectValues.autoIncrement + "</td>";87 itemData += "<td>" + objectValues.collation + "</td>";88 itemData += "<td>" + objectValues.dataMb + "</td>";89 itemData += "<td>" + objectValues.indexMb + "</td>";90 itemData += "<td>" + objectValues.allMb + "</td>";91 itemData += "<td>" + objectValues.count + "</td>";92 itemData += "<td>";93 itemData += "&nbsp;&nbsp;&nbsp;<a href='#' >删除</a>";94 itemData += "&nbsp;&nbsp;&nbsp;<a href='./tables-detail.html?id="+id+"&name="+objectValues.name+ "' target='_blank' >查看</a>";95 itemData += "</td>";96 itemData += "</tr>";97 });98 $(".tableDescsMain table").append(itemData);99}100/**101 * 获取地址栏 url 的参数信息102 * @param name103 * @returns {*}104 */105function getUrlParam(name) {106 var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象107 var r = window.location.search.substr(1).match(reg); //匹配目标参数108 if (r != null) return unescape(r[2]);109 return null; //返回参数值...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { objectValues } = require('jest-extended');2const obj = { a: 1, b: 2, c: 3 };3const values = objectValues(obj);4const _ = require('lodash');5const obj = { a: 1, b: 2, c: 3 };6const values = _.values(obj);7const _ = require('underscore');8const obj = { a: 1, b: 2, c: 3 };9const values = _.values(obj);10const objectValues = require('object.values');11const obj = { a: 1, b: 2, c: 3 };12const values = objectValues(obj);13const objectValues = require('object.values');14const obj = { a: 1, b: 2, c: 3 };15const values = objectValues(obj);16const objectValues = require('object.values');17const obj = { a: 1, b: 2, c: 3 };18const values = objectValues(obj);19const objectValues = require('object.values');20const obj = { a: 1, b: 2, c: 3 };21const values = objectValues(obj);22const objectValues = require('object.values');23const obj = { a: 1, b: 2, c: 3 };24const values = objectValues(obj);

Full Screen

Using AI Code Generation

copy

Full Screen

1const { objectValues } = require('jest-extended');2test('objectValues', () => {3 const obj = { a: 1, b: 2 };4 expect(objectValues(obj)).toEqual([1, 2]);5});6const { objectValues } = require('jest-extended');7test('objectValues', () => {8 const obj = { a: 1, b: 2 };9 expect(objectValues(obj)).toEqual([1, 2]);10});11import { objectValues } from 'jest-extended';12test('objectValues', () => {13 const obj = { a: 1, b: 2 };14 expect(objectValues(obj)).toEqual([1, 2]);15});16import { objectValues } from 'jest-extended';17test('objectValues', () => {18 const obj = { a: 1, b: 2 };19 expect(objectValues(obj)).toEqual([1, 2]);20});21import { objectValues } from 'jest-extended';22test('objectValues', () => {23 const obj = { a: 1, b: 2 };24 expect(objectValues(obj)).toEqual([1, 2]);25});26import { objectValues } from 'jest-extended';27test('objectValues', () => {28 const obj = { a: 1, b: 2 };29 expect(objectValues(obj)).toEqual([1, 2]);30});31import { objectValues } from 'jest-extended';32test('objectValues', () => {33 const obj = { a: 1, b: 2 };34 expect(objectValues(obj)).toEqual([1, 2]);35});36import { objectValues } from 'jest-extended';37test('objectValues', () => {

Full Screen

Using AI Code Generation

copy

Full Screen

1const { objectValues } = require('jest-extended')2const obj = { a: 1, b: 2, c: 3 }3const values = objectValues(obj)4const { values } = require('lodash')5const obj = { a: 1, b: 2, c: 3 }6const values = values(obj)7const objectValues = require('object.values')8const obj = { a: 1, b: 2, c: 3 }9const values = objectValues(obj)10const objectValues = require('object.values')11const obj = { a: 1, b: 2, c: 3 }12const values = objectValues(obj)13const objectValues = require('object.values')14const obj = { a: 1, b: 2, c: 3 }15const values = objectValues(obj)16const objectValues = require('object.values')17const obj = { a: 1, b: 2, c: 3 }18const values = objectValues(obj)19const objectValues = require('object.values')20const obj = { a: 1, b: 2, c: 3 }21const values = objectValues(obj)22const objectValues = require('object.values')23const obj = { a: 1, b: 2, c: 3 }24const values = objectValues(obj)

Full Screen

Using AI Code Generation

copy

Full Screen

1const objectValues = require('jest-extended').objectValues;2const obj = { a: 1, b: 2, c: 3 };3const result = objectValues(obj);4const objectValues = require('lodash').values;5const obj = { a: 1, b: 2, c: 3 };6const result = objectValues(obj);7const objectValues = require('underscore').values;8const obj = { a: 1, b: 2, c: 3 };9const result = objectValues(obj);10const objectValues = require('object.values');11const obj = { a: 1, b: 2, c: 3 };12const result = objectValues(obj);13const objectValues = require('object.values');14const obj = { a: 1, b: 2, c: 3 };15const result = objectValues(obj);16const objectValues = require('object.values');17const obj = { a: 1, b: 2, c: 3 };18const result = objectValues(obj);19const objectValues = require('object.values');20const obj = { a: 1, b: 2, c: 3 };21const result = objectValues(obj);22const objectValues = require('object.values');23const obj = { a: 1, b: 2, c: 3 };24const result = objectValues(obj);25const objectValues = require('object.values');26const obj = { a:

Full Screen

Using AI Code Generation

copy

Full Screen

1const objectValues = require('jest-extended').objectValues;2const obj = {a: 1, b: 2, c: 3};3import { objectValues } from 'jest-extended';4const obj = {a: 1, b: 2, c: 3};5objectValues(obj)6const obj = { a: 1, b: 2, c: 3 };

Full Screen

Using AI Code Generation

copy

Full Screen

1const objectValues = require('jest-extended').objectValues;2expect(objectValues({a: 1, b: 2})).toEqual([1, 2]);3const objectValues = require('lodash').values;4expect(objectValues({a: 1, b: 2})).toEqual([1, 2]);5const objectValues = Object.values;6expect(objectValues({a: 1, b: 2})).toEqual([1, 2]);7const objectValues = Object.keys;8expect(objectValues({a: 1, b: 2})).toEqual(['a', 'b']);9const objectValues = Object.getOwnPropertyNames;10expect(objectValues({a: 1, b: 2})).toEqual(['a', 'b']);11const objectValues = Object.getOwnPropertySymbols;12expect(objectValues({a: 1, b: 2})).toEqual([]);13const objectValues = Object.entries;14expect(objectValues({a: 1, b: 2})).toEqual([['a', 1], ['b', 2]]);15const objectValues = Object.getOwnPropertyDescriptors;16expect(objectValues({a: 1, b: 2})).toEqual({17 a: {value: 1, writable: true, enumerable: true, configurable: true},18 b: {value: 2, writable: true, enumerable: true, configurable: true},19});20const objectValues = Object.prototype.propertyIsEnumerable;21expect(objectValues({a: 1, b: 2})).toEqual(true);22const objectValues = Object.prototype.isPrototypeOf;23expect(objectValues({a: 1, b: 2})).toEqual(true);24const objectValues = Object.prototype.toString;25expect(objectValues({a: 1, b: 2})).toEqual('[object Object]');26const objectValues = Object.prototype.toLocaleString;27expect(objectValues({a: 1, b:

Full Screen

Using AI Code Generation

copy

Full Screen

1const { objectValues } = require('jest-extended');2const { values } = require('lodash');3const testObject = { a: 1, b: 2, c: 3 };4Jest - expect.anything()5Jest - expect.any()6Jest - expect.not.objectContaining()7Jest - expect.objectContaining()8Jest - expect.not.stringMatching()9Jest - expect.stringMatching()10Jest - expect.not.stringContaining()11Jest - expect.stringContaining()12Jest - expect.not.stringMatching()

Full Screen

Using AI Code Generation

copy

Full Screen

1const objectValues = require('jest-extended').objectValues;2const object = { a: 1, b: 2, c: 3 };3const result = objectValues(object);4console.log(result);5const _ = require('lodash');6const object = { a: 1, b: 2, c: 3 };7const result = _.values(object);8console.log(result);9const _ = require('lodash');10const object = { a: 1, b: 2, c: 3 };11const result = _.values(object);12console.log(result);13const _ = require('lodash');14const object = { a: 1, b: 2, c: 3 };15const result = _.values(object);16console.log(result);17const _ = require('lodash');18const object = { a: 1, b: 2, c: 3 };19const result = _.values(object);20console.log(result);21const _ = require('lodash');22const object = { a: 1, b: 2, c: 3 };23const result = _.values(object);24console.log(result);25const _ = require('lodash');26const object = { a: 1, b: 2, c: 3 };27const result = _.values(object);28console.log(result);29const _ = require('lodash');30const object = { a: 1, b: 2, c:

Full Screen

Using AI Code Generation

copy

Full Screen

1const objectValues = require('jest-extended').objectValues;2describe('objectValues', () => {3 it('should return an array of the values of the object', () => {4 const obj = { foo: 'bar', baz: 1 };5 const values = objectValues(obj);6 expect(values).toEqual(['bar', 1]);7 });8});9const objectValues = require('jest-extended').objectValues;10describe('objectValues', () => {11 it('should return an array of the values of the object', () => {12 const obj = { foo: 'bar', baz: 1 };13 const values = objectValues(obj);14 expect(values).toEqual(['bar', 1]);15 });16});17const objectValues = require('jest-extended').objectValues;18describe('objectValues', () => {19 it('should return an array of the values of the object', () => {20 const obj = { foo: 'bar', baz: 1 };21 const values = objectValues(obj);22 expect(values).toEqual(['bar', 1]);23 });24});25const objectValues = require('jest-extended').objectValues;26describe('objectValues', () => {27 it('should return an array of the values of the object', () => {28 const obj = { foo: 'bar', baz: 1 };29 const values = objectValues(obj);30 expect(values).toEqual(['bar', 1]);31 });32});33const objectValues = require('jest-extended').objectValues;34describe('objectValues', () => {35 it('should return an array of the values of the object', () => {36 const obj = { foo: 'bar', baz: 1 };37 const values = objectValues(obj);38 expect(values).toEqual(['bar', 1]);39 });40});41const objectValues = require('jest-extended').objectValues;42describe('objectValues', () => {43 it('should return an array of the values of the object

Full Screen

Using AI Code Generation

copy

Full Screen

1import { objectValues } from 'jest-extended';2const obj = {3};4describe('objectValues', () => {5 it('should return an array of values from object', () => {6 expect(objectValues(obj)).toEqual([1, 2, 3]);7 });8});9import { objectValues } from 'jest-extended';10const obj = {11};12describe('objectValues', () => {13 it('should return an array of values from object', () => {14 expect(objectValues(obj)).toEqual([1, 2, 3]);15 });16});17import { objectValues } from 'jest-extended';18const obj = {19};20describe('objectValues', () => {21 it('should return an array of values from object', () => {22 expect(objectValues(obj)).toEqual([1, 2, 3]);23 });24});25import { objectValues } from 'jest-extended';26const obj = {27};28describe('objectValues', () => {29 it('should return an array of values from object', () => {30 expect(objectValues(obj)).toEqual([1, 2, 3]);31 });32});33import { objectValues } from 'jest-extended';34const obj = {35};36describe('objectValues', () => {37 it('should return an array of values from object', () => {38 expect(objectValues(obj)).toEqual([1, 2, 3]);39 });40});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run jest-extended automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful