mirror of
https://github.com/cse110-fa22-group29/cse110-fa22-group29.git
synced 2024-11-10 13:44:45 +00:00
1718c7cedb
update main,js to rquire localStroage, add simple unit tests to localStroage.test.js, create symlink of testenv.js to source/assets/scripts, update package.json with proper recursive call Signed-off-by: Arthur Lu <learthurgo@gmail.com>
27 lines
724 B
JavaScript
27 lines
724 B
JavaScript
const {getReviewsFromStorage, saveReviewsToStorage} = require("./localStorage");
|
|
const {environment} = require("./testenv");
|
|
const assert = require("assert");
|
|
const {describe, it, beforeEach} = require("mocha");
|
|
|
|
beforeEach(() => {
|
|
window = environment();
|
|
localStorage = window.localStorage;
|
|
});
|
|
|
|
describe("test app localStorage interaction", () => {
|
|
it("get after init", () => {
|
|
assert.deepEqual(getReviewsFromStorage(), []);
|
|
});
|
|
it("store one then get", () => {
|
|
reviews = [{
|
|
"imgSrc": "sample src",
|
|
"imgAlt": "sample alt",
|
|
"mealName": "sample name",
|
|
"restaurant": "sample restaurant",
|
|
"rating": 5
|
|
}];
|
|
|
|
saveReviewsToStorage(reviews);
|
|
assert.deepEqual(getReviewsFromStorage(), reviews);
|
|
})
|
|
}); |