|
| 1 | +import Compare from "../comparison"; |
| 2 | + |
| 3 | +describe("Comparison Tests", () => { |
| 4 | + describe("Core Logic", () => { |
| 5 | + it("should return an array of users who are in the following list but not the followers list", () => { |
| 6 | + const followers = ["Alice", "Brenda"]; |
| 7 | + const following = ["Alice", "Brenda", "Charlie"]; |
| 8 | + const result = Compare(following, followers); |
| 9 | + |
| 10 | + expect(result).toEqual(["Charlie"]); |
| 11 | + }); |
| 12 | + |
| 13 | + it("should return an empty array when both lists are empty", () => { |
| 14 | + const followers: string[] = []; |
| 15 | + const following: string[] = []; |
| 16 | + const result = Compare(following, followers); |
| 17 | + |
| 18 | + expect(result).toEqual([]); |
| 19 | + }); |
| 20 | + |
| 21 | + it("should return the entire following list if there are not followers to compare to", () => { |
| 22 | + const followers: string[] = []; |
| 23 | + const following = ["Alice", "Brenda", "Charlie", "David"]; |
| 24 | + const result = Compare(following, followers); |
| 25 | + |
| 26 | + expect(result).toEqual(following); |
| 27 | + }); |
| 28 | + }); |
| 29 | + |
| 30 | + describe("Business Logic", () => { |
| 31 | + it("should return ex-friend if my ex-friend unfollowed me", () => { |
| 32 | + const followers = ["friend"]; |
| 33 | + const following = ["friend", "ex_friend"]; |
| 34 | + const result = Compare(following, followers); |
| 35 | + |
| 36 | + expect(result).toEqual(["ex_friend"]); |
| 37 | + }); |
| 38 | + |
| 39 | + it("should return only celebrities that I expect when no one unfollows me", () => { |
| 40 | + const followers = ["friend", "friend_2"]; |
| 41 | + const following = ["friend", "friend_2", "POTUS", "Tom_Cruise"]; |
| 42 | + const result = Compare(following, followers); |
| 43 | + |
| 44 | + expect(result).toEqual(["POTUS", "Tom_Cruise"]); |
| 45 | + }); |
| 46 | + |
| 47 | + it("should return no accounts when I don't follow accounts who follow me", () => { |
| 48 | + const followers = ["friend", "friend_2", "spam_bot"]; |
| 49 | + const following = ["friend", "friend_2"]; |
| 50 | + const result = Compare(following, followers); |
| 51 | + |
| 52 | + expect(result).toEqual([]); |
| 53 | + }); |
| 54 | + |
| 55 | + it("should return ex-friend AND celebrity accounts when my ex-friend unfollows me and I follow brand / celerity accounts I don't expect to follow me back", () => { |
| 56 | + const followers = ["friend"]; |
| 57 | + const following = ["friend", "ex_friend", "POTUS", "Tom_Cruise"]; |
| 58 | + const result = Compare(following, followers); |
| 59 | + |
| 60 | + expect(result).toEqual(["ex_friend", "POTUS", "Tom_Cruise"]); |
| 61 | + }); |
| 62 | + |
| 63 | + }); |
| 64 | +}); |
0 commit comments