|
1 | 1 | import adaptRecipients, {
|
2 | 2 | adaptSingleRecipient,
|
| 3 | + adaptReplyToRecipient, |
3 | 4 | } from "../../adapters/recipients";
|
4 | 5 |
|
5 | 6 | describe("adapters/recipients: ", () => {
|
@@ -85,4 +86,60 @@ describe("adapters/recipients: ", () => {
|
85 | 86 | expect(result).toEqual(expectedResult);
|
86 | 87 | });
|
87 | 88 | });
|
| 89 | + |
| 90 | + describe("adaptReplyToRecipient(): ", () => { |
| 91 | + it("returns undefined if recipients is invalid.", () => { |
| 92 | + const recipients = undefined; |
| 93 | + |
| 94 | + const expectedResult = undefined; |
| 95 | + const result = adaptReplyToRecipient(recipients); |
| 96 | + |
| 97 | + expect(result).toEqual(expectedResult); |
| 98 | + }); |
| 99 | + |
| 100 | + it("returns undefined if recipients is empty array.", () => { |
| 101 | + const recipients: any = []; |
| 102 | + |
| 103 | + const expectedResult = undefined; |
| 104 | + const result = adaptReplyToRecipient(recipients); |
| 105 | + |
| 106 | + expect(result).toEqual(expectedResult); |
| 107 | + }); |
| 108 | + |
| 109 | + it("returns adapted recipients if it's not an array.", () => { |
| 110 | + const recipients = { |
| 111 | + name: "mock-name", |
| 112 | + address: "mock-email", |
| 113 | + }; |
| 114 | + |
| 115 | + const expectedResult = { |
| 116 | + name: recipients.name, |
| 117 | + email: recipients.address, |
| 118 | + }; |
| 119 | + const result = adaptReplyToRecipient(recipients); |
| 120 | + |
| 121 | + expect(result).toEqual(expectedResult); |
| 122 | + }); |
| 123 | + |
| 124 | + it("returns first adapted recipient if it's an array.", () => { |
| 125 | + const recipients = [ |
| 126 | + { |
| 127 | + name: "mock-name-1", |
| 128 | + address: "mock-email-1", |
| 129 | + }, |
| 130 | + { |
| 131 | + name: "mock-name-2", |
| 132 | + address: "mock-email-2", |
| 133 | + }, |
| 134 | + ]; |
| 135 | + |
| 136 | + const expectedResult = { |
| 137 | + name: recipients[0].name, |
| 138 | + email: recipients[0].address, |
| 139 | + }; |
| 140 | + const result = adaptReplyToRecipient(recipients); |
| 141 | + |
| 142 | + expect(result).toEqual(expectedResult); |
| 143 | + }); |
| 144 | + }); |
88 | 145 | });
|
0 commit comments