mirror of
https://github.com/cse110-fa22-group29/cse110-fa22-group29.git
synced 2024-12-27 09:29:10 +00:00
fix some linting issues,
fix bug in localStroage unit tests Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
parent
39aa535864
commit
af4378ee40
@ -112,13 +112,15 @@ describe("test sort/filter localStorage interaction", () => {
|
|||||||
|
|
||||||
it("add sample data for sort and filter", () => {
|
it("add sample data for sort and filter", () => {
|
||||||
for(let i = 0; i < 100; i++){
|
for(let i = 0; i < 100; i++){
|
||||||
let new_review = {
|
let review = {
|
||||||
"imgSrc": `sample src ${i}`,
|
"imgSrc": `sample src ${i}`,
|
||||||
"mealName": `sample name ${i}`,
|
"mealName": `sample name ${i}`,
|
||||||
"restaurant": `sample restaurant ${i}`,
|
"restaurant": `sample restaurant ${i}`,
|
||||||
"rating": i,
|
"rating": i,
|
||||||
"tags": [`tag ${i%3}`, `tag ${i < 50}`, "tag x"]
|
"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 = [];
|
let specific_tagged_reviews = [];
|
||||||
|
|
||||||
specific_tagged_reviews = getReviewsByTag("tag 0");
|
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++){
|
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].tags.includes("tag 0"), true);
|
||||||
assert.strictEqual(specific_tagged_reviews[i].reviewID % 3, 0);
|
assert.strictEqual(specific_tagged_reviews[i].reviewID % 3, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
specific_tagged_reviews = getReviewsByTag("tag 1");
|
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++){
|
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].tags.includes("tag 1"), true);
|
||||||
assert.strictEqual(specific_tagged_reviews[i].reviewID % 3, 1);
|
assert.strictEqual(specific_tagged_reviews[i].reviewID % 3, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
specific_tagged_reviews = getReviewsByTag("tag 2");
|
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++){
|
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].tags.includes("tag 2"), true);
|
||||||
assert.strictEqual(specific_tagged_reviews[i].reviewID % 3, 2);
|
assert.strictEqual(specific_tagged_reviews[i].reviewID % 3, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
specific_tagged_reviews = getReviewsByTag("tag true");
|
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++){
|
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].tags.includes("tag true"), true);
|
||||||
assert.strictEqual(specific_tagged_reviews[i].reviewID < 50, true);
|
assert.strictEqual(specific_tagged_reviews[i].reviewID < 50, true);
|
||||||
@ -205,35 +207,35 @@ describe("test sort/filter localStorage interaction", () => {
|
|||||||
let specific_tagged_reviews = [];
|
let specific_tagged_reviews = [];
|
||||||
|
|
||||||
specific_tagged_reviews = getReviewsByTag("tag 0");
|
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++){
|
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].tags.includes("tag 0"), true);
|
||||||
assert.strictEqual(specific_tagged_reviews[i].reviewID % 4, 0);
|
assert.strictEqual(specific_tagged_reviews[i].reviewID % 4, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
specific_tagged_reviews = getReviewsByTag("tag 1");
|
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++){
|
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].tags.includes("tag 1"), true);
|
||||||
assert.strictEqual(specific_tagged_reviews[i].reviewID % 4, 1);
|
assert.strictEqual(specific_tagged_reviews[i].reviewID % 4, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
specific_tagged_reviews = getReviewsByTag("tag 2");
|
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++){
|
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].tags.includes("tag 2"), true);
|
||||||
assert.strictEqual(specific_tagged_reviews[i].reviewID % 4, 2);
|
assert.strictEqual(specific_tagged_reviews[i].reviewID % 4, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
specific_tagged_reviews = getReviewsByTag("tag 3");
|
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++){
|
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].tags.includes("tag 3"), true);
|
||||||
assert.strictEqual(specific_tagged_reviews[i].reviewID % 4, 3);
|
assert.strictEqual(specific_tagged_reviews[i].reviewID % 4, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
specific_tagged_reviews = getReviewsByTag("tag true");
|
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++){
|
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].tags.includes("tag true"), true);
|
||||||
assert.strictEqual(specific_tagged_reviews[i].reviewID < 37, true);
|
assert.strictEqual(specific_tagged_reviews[i].reviewID < 37, true);
|
||||||
|
Loading…
Reference in New Issue
Block a user