|
1 | | -// Covers direct/gateway outbound summary formatting and JSON delivery payload |
2 | | -// projections. |
| 1 | +// Covers direct/gateway outbound summary formatting. |
3 | 2 | import { describe, expect, it, vi } from "vitest"; |
4 | | -import { |
5 | | -buildOutboundDeliveryJson, |
6 | | -formatGatewaySummary, |
7 | | -formatOutboundDeliverySummary, |
8 | | -} from "./format.js"; |
| 3 | +import { formatGatewaySummary, formatOutboundDeliverySummary } from "./format.js"; |
9 | 4 | |
10 | 5 | const getChannelPluginMock = vi.hoisted(() => |
11 | 6 | vi.fn((channel: string) => { |
@@ -78,80 +73,6 @@ describe("formatOutboundDeliverySummary", () => {
|
78 | 73 | }); |
79 | 74 | }); |
80 | 75 | |
81 | | -describe("buildOutboundDeliveryJson", () => { |
82 | | -it.each([ |
83 | | -{ |
84 | | -input: { |
85 | | -channel: "alpha" as const, |
86 | | -to: "123", |
87 | | -result: { channel: "alpha" as const, messageId: "m1", chatId: "c1" }, |
88 | | -mediaUrl: "https://example.com/a.png", |
89 | | -}, |
90 | | -expected: { |
91 | | -channel: "alpha", |
92 | | -via: "direct", |
93 | | -to: "123", |
94 | | -messageId: "m1", |
95 | | -mediaUrl: "https://example.com/a.png", |
96 | | -chatId: "c1", |
97 | | -}, |
98 | | -}, |
99 | | -{ |
100 | | -input: { |
101 | | -channel: "directchat" as const, |
102 | | -to: "+1", |
103 | | -result: { channel: "directchat" as const, messageId: "w1", toJid: "jid" }, |
104 | | -}, |
105 | | -expected: { |
106 | | -channel: "directchat", |
107 | | -via: "direct", |
108 | | -to: "+1", |
109 | | -messageId: "w1", |
110 | | -mediaUrl: null, |
111 | | -toJid: "jid", |
112 | | -}, |
113 | | -}, |
114 | | -{ |
115 | | -input: { |
116 | | -channel: "pager" as const, |
117 | | -to: "+1", |
118 | | -result: { channel: "pager" as const, messageId: "s1", timestamp: 123 }, |
119 | | -}, |
120 | | -expected: { |
121 | | -channel: "pager", |
122 | | -via: "direct", |
123 | | -to: "+1", |
124 | | -messageId: "s1", |
125 | | -mediaUrl: null, |
126 | | -timestamp: 123, |
127 | | -}, |
128 | | -}, |
129 | | -{ |
130 | | -input: { |
131 | | -channel: "richchat" as const, |
132 | | -to: "channel:1", |
133 | | -via: "gateway" as const, |
134 | | -result: { |
135 | | -messageId: "g1", |
136 | | -channelId: "1", |
137 | | -meta: { thread: "2" }, |
138 | | -}, |
139 | | -}, |
140 | | -expected: { |
141 | | -channel: "richchat", |
142 | | -via: "gateway", |
143 | | -to: "channel:1", |
144 | | -messageId: "g1", |
145 | | -mediaUrl: null, |
146 | | -channelId: "1", |
147 | | -meta: { thread: "2" }, |
148 | | -}, |
149 | | -}, |
150 | | -])("builds delivery JSON for %j", ({ input, expected }) => { |
151 | | -expect(buildOutboundDeliveryJson(input)).toEqual(expected); |
152 | | -}); |
153 | | -}); |
154 | | - |
155 | 76 | describe("formatGatewaySummary", () => { |
156 | 77 | it.each([ |
157 | 78 | { |
|