mirror of
https://github.com/cse110-fa22-group29/cse110-fa22-group29.git
synced 2024-12-27 09:29:10 +00:00
add another unit test to localStorage.test.js,
reflect fixes to packages.json from main
This commit is contained in:
parent
c168d0f902
commit
b85a73400d
@ -4,7 +4,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "mocha --recursive './{,!(node_modules)/**}/*.test.js'",
|
"test": "mocha --recursive './{,!(node_modules)/**}/*.test.js'",
|
||||||
"lint": "eslint **/*.js",
|
"lint": "eslint **/*.js",
|
||||||
"fix-style": "eslint --fix **/*.js"
|
"fix-style": "eslint --fix '**/*.js'"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "^8.27.0",
|
"eslint": "^8.27.0",
|
||||||
|
@ -13,15 +13,37 @@ describe("test app localStorage interaction", () => {
|
|||||||
assert.deepEqual(getReviewsFromStorage(), []);
|
assert.deepEqual(getReviewsFromStorage(), []);
|
||||||
});
|
});
|
||||||
it("store one then get", () => {
|
it("store one then get", () => {
|
||||||
reviews = [{
|
let reviews = [{
|
||||||
"imgSrc": "sample src",
|
"imgSrc": "sample src",
|
||||||
"imgAlt": "sample alt",
|
"imgAlt": "sample alt",
|
||||||
"mealName": "sample name",
|
"mealName": "sample name",
|
||||||
"restaurant": "sample restaurant",
|
"restaurant": "sample restaurant",
|
||||||
"rating": 5
|
"rating": 5,
|
||||||
|
"tags": ["tag 1", "tag 2", "tag 3"]
|
||||||
}];
|
}];
|
||||||
|
|
||||||
saveReviewsToStorage(reviews);
|
saveReviewsToStorage(reviews);
|
||||||
assert.deepEqual(getReviewsFromStorage(), 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);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
Loading…
Reference in New Issue
Block a user