diff --git a/source/assets/scripts/localStorage.test.js b/source/assets/scripts/localStorage.test.js index 6e4d108..3330ba0 100644 --- a/source/assets/scripts/localStorage.test.js +++ b/source/assets/scripts/localStorage.test.js @@ -112,13 +112,15 @@ describe("test sort/filter localStorage interaction", () => { it("add sample data for sort and filter", () => { for(let i = 0; i < 100; i++){ - let new_review = { + let review = { "imgSrc": `sample src ${i}`, "mealName": `sample name ${i}`, "restaurant": `sample restaurant ${i}`, "rating": i, "tags": [`tag ${i%3}`, `tag ${i < 50}`, "tag x"] }; + + newReviewToStorage(review); } }); @@ -136,28 +138,28 @@ describe("test sort/filter localStorage interaction", () => { let specific_tagged_reviews = []; specific_tagged_reviews = getReviewsByTag("tag 0"); - assert.strictEqual(specific_tagged_reviews.length, 34) + assert.strictEqual(specific_tagged_reviews.length, 34); for(let i = 0; i < specific_tagged_reviews.length; i++){ assert.strictEqual(specific_tagged_reviews[i].tags.includes("tag 0"), true); assert.strictEqual(specific_tagged_reviews[i].reviewID % 3, 0); } specific_tagged_reviews = getReviewsByTag("tag 1"); - assert.strictEqual(specific_tagged_reviews.length, 33) + assert.strictEqual(specific_tagged_reviews.length, 33); for(let i = 0; i < specific_tagged_reviews.length; i++){ assert.strictEqual(specific_tagged_reviews[i].tags.includes("tag 1"), true); assert.strictEqual(specific_tagged_reviews[i].reviewID % 3, 1); } specific_tagged_reviews = getReviewsByTag("tag 2"); - assert.strictEqual(specific_tagged_reviews.length, 33) + assert.strictEqual(specific_tagged_reviews.length, 33); for(let i = 0; i < specific_tagged_reviews.length; i++){ assert.strictEqual(specific_tagged_reviews[i].tags.includes("tag 2"), true); assert.strictEqual(specific_tagged_reviews[i].reviewID % 3, 2); } specific_tagged_reviews = getReviewsByTag("tag true"); - assert.strictEqual(specific_tagged_reviews.length, 50) + assert.strictEqual(specific_tagged_reviews.length, 50); for(let i = 0; i < specific_tagged_reviews.length; i++){ assert.strictEqual(specific_tagged_reviews[i].tags.includes("tag true"), true); assert.strictEqual(specific_tagged_reviews[i].reviewID < 50, true); @@ -205,35 +207,35 @@ describe("test sort/filter localStorage interaction", () => { let specific_tagged_reviews = []; specific_tagged_reviews = getReviewsByTag("tag 0"); - assert.strictEqual(specific_tagged_reviews.length, 25) + assert.strictEqual(specific_tagged_reviews.length, 25); for(let i = 0; i < specific_tagged_reviews.length; i++){ assert.strictEqual(specific_tagged_reviews[i].tags.includes("tag 0"), true); assert.strictEqual(specific_tagged_reviews[i].reviewID % 4, 0); } specific_tagged_reviews = getReviewsByTag("tag 1"); - assert.strictEqual(specific_tagged_reviews.length, 25) + assert.strictEqual(specific_tagged_reviews.length, 25); for(let i = 0; i < specific_tagged_reviews.length; i++){ assert.strictEqual(specific_tagged_reviews[i].tags.includes("tag 1"), true); assert.strictEqual(specific_tagged_reviews[i].reviewID % 4, 1); } specific_tagged_reviews = getReviewsByTag("tag 2"); - assert.strictEqual(specific_tagged_reviews.length, 25) + assert.strictEqual(specific_tagged_reviews.length, 25); for(let i = 0; i < specific_tagged_reviews.length; i++){ assert.strictEqual(specific_tagged_reviews[i].tags.includes("tag 2"), true); assert.strictEqual(specific_tagged_reviews[i].reviewID % 4, 2); } specific_tagged_reviews = getReviewsByTag("tag 3"); - assert.strictEqual(specific_tagged_reviews.length, 25) + assert.strictEqual(specific_tagged_reviews.length, 25); for(let i = 0; i < specific_tagged_reviews.length; i++){ assert.strictEqual(specific_tagged_reviews[i].tags.includes("tag 3"), true); assert.strictEqual(specific_tagged_reviews[i].reviewID % 4, 3); } specific_tagged_reviews = getReviewsByTag("tag true"); - assert.strictEqual(specific_tagged_reviews.length, 37) + assert.strictEqual(specific_tagged_reviews.length, 37); for(let i = 0; i < specific_tagged_reviews.length; i++){ assert.strictEqual(specific_tagged_reviews[i].tags.includes("tag true"), true); assert.strictEqual(specific_tagged_reviews[i].reviewID < 37, true);