mirror of
https://github.com/cse110-fa22-group29/cse110-fa22-group29.git
synced 2024-11-10 13:44:45 +00:00
b85a73400d
reflect fixes to packages.json from main
49 lines
1.3 KiB
JavaScript
49 lines
1.3 KiB
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", () => {
|
|
let reviews = [{
|
|
"imgSrc": "sample src",
|
|
"imgAlt": "sample alt",
|
|
"mealName": "sample name",
|
|
"restaurant": "sample restaurant",
|
|
"rating": 5,
|
|
"tags": ["tag 1", "tag 2", "tag 3"]
|
|
}];
|
|
|
|
saveReviewsToStorage(reviews);
|
|
assert.deepEqual(getReviewsFromStorage(), reviews);
|
|
});
|
|
it("repeated store one more and get", () => {
|
|
saveReviewsToStorage(reviews);
|
|
assert.deepEqual(getReviewsFromStorage(), reviews);
|
|
|
|
for(let i = 0; i < 1000; i++){
|
|
reviews = getReviewsFromStorage();
|
|
|
|
reviews.push(
|
|
{
|
|
"imgSrc": `sample src ${i}`,
|
|
"imgAlt": `sample alt ${i}`,
|
|
"mealName": `sample name ${i}`,
|
|
"restaurant": `sample restaurant ${i}`,
|
|
"rating": i,
|
|
"tags": [`tag ${3*i}`, `tag ${3*i + 1}`, `tag ${3*i + 2}`]
|
|
}
|
|
)
|
|
saveReviewsToStorage(reviews);
|
|
assert.deepEqual(getReviewsFromStorage(), reviews);
|
|
}
|
|
});
|
|
}); |