@capillarytech/creatives-library 8.0.115 → 8.0.116
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/utils/commonUtils.js
CHANGED
|
@@ -35,7 +35,7 @@ export const addBaseToTemplate = (template) => {
|
|
|
35
35
|
...template.versions,
|
|
36
36
|
base: {
|
|
37
37
|
...history[0],
|
|
38
|
-
...(
|
|
38
|
+
...( get(template, 'versions.base.subject') ? {subject : get(template, 'versions.base.subject')} :{ subject:history?.[0]?.subject }),
|
|
39
39
|
},
|
|
40
40
|
},
|
|
41
41
|
});
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
validateMobilePushContent,
|
|
4
4
|
validateInAppContent,
|
|
5
5
|
getChannelData,
|
|
6
|
-
extractContent
|
|
6
|
+
extractContent,addBaseToTemplate
|
|
7
7
|
} from "../commonUtils";
|
|
8
8
|
import { SMS_TRAI_VAR } from '../../v2Containers/SmsTrai/Edit/constants';
|
|
9
9
|
import { ANDROID, IOS } from '../../v2Containers/CreativesContainer/constants';
|
|
@@ -149,6 +149,48 @@ describe("validateLiquidTemplateContent", () => {
|
|
|
149
149
|
});
|
|
150
150
|
expect(onSuccess).not.toHaveBeenCalled();
|
|
151
151
|
});
|
|
152
|
+
|
|
153
|
+
describe("addBaseToTemplate - subject property logic", () => {
|
|
154
|
+
it("should use template.versions.base.subject if it exists", () => {
|
|
155
|
+
const template = {
|
|
156
|
+
versions: {
|
|
157
|
+
base: { subject: "base-subject" },
|
|
158
|
+
history: [{ subject: "history-subject" }],
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
const result = addBaseToTemplate(template);
|
|
162
|
+
expect(result.versions.base.subject).toBe("base-subject");
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it("should use history[0].subject if template.versions.base.subject does not exist", () => {
|
|
166
|
+
const template = {
|
|
167
|
+
versions: {
|
|
168
|
+
history: [{ subject: "history-subject" }],
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
const result = addBaseToTemplate(template);
|
|
172
|
+
expect(result.versions.base.subject).toBe("history-subject");
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it("should set subject as undefined if neither exists", () => {
|
|
176
|
+
const template = {
|
|
177
|
+
versions: {
|
|
178
|
+
history: [{}],
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
const result = addBaseToTemplate(template);
|
|
182
|
+
expect(result.versions.base.subject).toBeUndefined();
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it("should return the original template if history is empty", () => {
|
|
186
|
+
const template = {
|
|
187
|
+
versions: {
|
|
188
|
+
history: [],
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
expect(addBaseToTemplate(template)).toEqual(template);
|
|
192
|
+
});
|
|
193
|
+
});
|
|
152
194
|
});
|
|
153
195
|
|
|
154
196
|
describe("validateMobilePushContent", () => {
|