forked from utsavll0/calorieApp_server
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from rishi2019194/ui-branch-3
add legend to graph, add javaScript assert tests for FE
- Loading branch information
Showing
4 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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({}, "[email protected]"); | ||
|
||
return $("#enroll").text() === "5" && ajaxCalled; | ||
}, "dashboard test failed"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters