diff --git a/static/js/tests.js b/static/js/tests.js new file mode 100644 index 00000000..787ace74 --- /dev/null +++ b/static/js/tests.js @@ -0,0 +1,88 @@ +console.assert(() => { + addToLocalStorage("testKey", "testData"); + return localStorage.getItem("testKey") === "testData"; +}, "addToLocalStorage test failed"); + +// Test retrieveFromLocalStorage function +localStorage.setItem("testRetrieveKey", "testRetrieveData"); +console.assert(() => { + return retrieveFromLocalStorage("testRetrieveKey") === "testRetrieveData"; +}, "retrieveFromLocalStorage test failed"); + + +console.assert(() => { + let ajaxCalled = false; + $.ajax = function(options) { + ajaxCalled = true; + options.success(); + }; + + logout(); + + return ajaxCalled; +}, "logout test failed"); + +// Test history function +console.assert(() => { + let ajaxCalled = false; + $.ajax = function(options) { + ajaxCalled = true; + options.success('{"date":"2023-01-01","calories":2000,"burnout":300}'); + }; + + history({ target: document.createElement('form') }); + + return $("#date").text() === "2023-01-01" && $("#calories").text() === "2000" && $("#burnout").text() === "300" && ajaxCalled; +}, "history test failed"); + +// Test sendRequest function +console.assert(() => { + let ajaxCalled = false; + $.ajax = function(options) { + ajaxCalled = true; + options.success('{}'); + }; + + sendRequest({}, "testReceiver"); + + return ajaxCalled; +}, "sendRequest test failed"); + +// Test cancelRequest function +console.assert(() => { + let ajaxCalled = false; + $.ajax = function(options) { + ajaxCalled = true; + options.success('{}'); + }; + + cancelRequest({}, "testReceiver"); + + return ajaxCalled; +}, "cancelRequest test failed"); + +// Test approveRequest function +console.assert(() => { + let ajaxCalled = false; + $.ajax = function(options) { + ajaxCalled = true; + options.success('{}'); + }; + + approveRequest({}, "testReceiver"); + + return ajaxCalled; +}, "approveRequest test failed"); + +// Test dashboard function +console.assert(() => { + let ajaxCalled = false; + $.ajax = function(options) { + ajaxCalled = true; + options.success('{"enroll":5}'); + }; + + dashboard({}, "test@email.com"); + + return $("#enroll").text() === "5" && ajaxCalled; +}, "dashboard test failed"); diff --git a/static/main.css b/static/main.css index 9238440b..943f899e 100644 --- a/static/main.css +++ b/static/main.css @@ -23,6 +23,42 @@ } + .legend { + display: flex; + align-items: center; + justify-content: space-around; + padding: 10px; + margin-left: 10rem; + flex-direction: column; + align-items: flex-start; + justify-content: space-around; + + } + + .legend div { + display: flex; + align-items: center; + } + + .legend label { + margin-bottom: 0px; + } + + .legend span { + display: inline-block; + width: 20px; + height: 20px; + margin-right: 5px; + } + + #calories-burnt { + background-color: rgba(220,20,60,0.91); + } + + #calories-consumed { + background-color: #84d320; + } + footer { margin-top: auto; } @@ -57,6 +93,13 @@ width: 55%; align-self: center; box-shadow: 0px 0px 95px -30px rgba(0, 0, 0, 0.15); + margin-left: auto; + margin-right: auto; + } + + .sign-in-div { + width: 55%; + margin: auto; } .content-section-container { diff --git a/templates/history.html b/templates/history.html index 59c69dd2..af4c1a65 100644 --- a/templates/history.html +++ b/templates/history.html @@ -101,6 +101,16 @@

Great job with the progress

}, }); +
+
+ + +
+
+ + +
+
diff --git a/templates/layout.html b/templates/layout.html index e5422980..b88d11bd 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -147,5 +147,6 @@
Newsletter
+ \ No newline at end of file