|
8 | 8 | DataFactory, |
9 | 9 | TransactionFactory, |
10 | 10 | TransactionReviewFactory, |
| 11 | + UserFactory, |
11 | 12 | } from "./data"; |
12 | 13 | import { CreateTransactionReviewRequest } from "src/types"; |
13 | 14 |
|
@@ -111,4 +112,40 @@ describe('transaction review tests', () => { |
111 | 112 | const response = await transactionReviewController.getTransactionReviews(); |
112 | 113 | expect(response.reviews).toHaveLength(2); |
113 | 114 | }); |
| 115 | + |
| 116 | + test("get transaction reviews filtered by sellerId", async () => { |
| 117 | + const seller = UserFactory.fakeTemplate2(); |
| 118 | + const buyer = UserFactory.fakeTemplate(); |
| 119 | + const otherSeller = UserFactory.fake(); |
| 120 | + const otherBuyer = UserFactory.fake(); |
| 121 | + |
| 122 | + const matchingTransaction = TransactionFactory.fake(); |
| 123 | + matchingTransaction.seller = seller; |
| 124 | + matchingTransaction.buyer = buyer; |
| 125 | + |
| 126 | + const otherTransaction = TransactionFactory.fake(); |
| 127 | + otherTransaction.seller = otherSeller; |
| 128 | + otherTransaction.buyer = otherBuyer; |
| 129 | + |
| 130 | + const matchingReview = TransactionReviewFactory.fake(); |
| 131 | + matchingReview.transaction = matchingTransaction; |
| 132 | + |
| 133 | + const otherReview = TransactionReviewFactory.fake(); |
| 134 | + otherReview.transaction = otherTransaction; |
| 135 | + |
| 136 | + await new DataFactory() |
| 137 | + .createUsers(seller, buyer, otherSeller, otherBuyer) |
| 138 | + .createTransactions(matchingTransaction, otherTransaction) |
| 139 | + .createTransactionReviews(matchingReview, otherReview) |
| 140 | + .write(); |
| 141 | + |
| 142 | + const response = await transactionReviewController.getTransactionReviews( |
| 143 | + seller.firebaseUid, |
| 144 | + ); |
| 145 | + |
| 146 | + expect(response.reviews).toHaveLength(1); |
| 147 | + expect(response.reviews[0].transaction.seller.firebaseUid).toEqual( |
| 148 | + seller.firebaseUid, |
| 149 | + ); |
| 150 | + }); |
114 | 151 | }); |
0 commit comments