@tapcart/mobile-components 0.8.73 → 0.9.1
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/dist/lib/utils.d.ts +2 -0
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +5 -3
- package/dist/lib/variablesCart.util.d.ts.map +1 -1
- package/dist/lib/variablesCart.util.js +6 -6
- package/dist/lib/variablesCart.util.test.js +12 -3
- package/dist/styles.css +6 -0
- package/dist/tests/utils.test.js +578 -1
- package/package.json +1 -1
package/dist/lib/utils.d.ts
CHANGED
|
@@ -139,6 +139,8 @@ export type TextStyle = {
|
|
|
139
139
|
uppercase: boolean;
|
|
140
140
|
textAlignment: "left" | "center" | "right" | "justify";
|
|
141
141
|
wrapText: boolean;
|
|
142
|
+
lineHeight?: number;
|
|
143
|
+
letterSpacing?: number;
|
|
142
144
|
};
|
|
143
145
|
type Headline = TextStyle;
|
|
144
146
|
type Subtext = TextStyle;
|
package/dist/lib/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,4BAA4B,EAC5B,yBAAyB,EACzB,UAAU,EACV,eAAe,EACf,OAAO,EACP,QAAQ,EACR,gBAAgB,EACjB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,UAAU,EAAQ,MAAM,MAAM,CAAA;AAMvC,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAErC,eAAO,MAAM,gBAAgB,UAAW,MAAM,YAAY,MAAM,gCACrC,CAAA;AAE3B,MAAM,MAAM,KAAK,GAAG;IAAE,IAAI,EAAE,QAAQ,GAAG,WAAW,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAEnE,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC;AAED,eA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qB,iBACnB,OAAO,MAAM,EAAE,KAAK,EAAE,CAAC,gBACvB,MAAM,EAAE,KACpB,KAAK,EAiCP,CAAA;AAMD,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,UAGnC;AAED,eAAO,MAAM,wBAAwB,UAAW,yBAAyB,WAOxE,CAAA;AAkHD,KAAK,QAAQ,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAExE,eAAO,MAAM,WAAW;cAMZ,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;CA4DnB,CAAA;AAED,eAAO,MAAM,iBAAiB,QAAS,GAAG,2BAC+B,CAAA;AAEzE,eAAO,MAAM,WAAW,QAAS,GAAG,wCACO,CAAA;AAE3C,eAAO,MAAM,yBAAyB,QAC/B,GAAG,EAAE,6BAGX,CAAA;AAED,eAAO,MAAM,mBAAmB,QACzB,GAAG,EAAE,0CAGX,CAAA;AA6BD,eAAO,MAAM,eAAe,aAChB,yBAAyB,cACvB,yBAAyB,YAoDtC,CAAA;AAGD,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,GAAG,CAAA;CACX,CAAA;AAED,KAAK,UAAU,GAAG;IAChB,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,KAAK,CAAA;IAC3B,UAAU,EAAE,CAAC,SAAS,GAAG,UAAU,CAAC,EAAE,CAAA;CACvC,CAAA;AAoDD,eAAO,MAAM,kBAAkB,UACtB,UAAU,WACR,GAAG,KACX,OAyBF,CAAA"}
|
package/dist/lib/utils.js
CHANGED
|
@@ -134,13 +134,15 @@ export const getBackgroundAndSpacingStyle = (backgroundAndSpacing) => {
|
|
|
134
134
|
};
|
|
135
135
|
};
|
|
136
136
|
export const getTextStyle = (textStyle) => {
|
|
137
|
-
const { font, size, color, uppercase, textAlignment, wrapText } = textStyle;
|
|
137
|
+
const { font, size, color, uppercase, textAlignment, wrapText, lineHeight, letterSpacing, } = textStyle;
|
|
138
138
|
const isItalic = font.family &&
|
|
139
139
|
typeof font.family === "string" &&
|
|
140
140
|
font.family.toLowerCase().includes("italic");
|
|
141
|
-
return Object.assign({ fontFamily: font.family === "initial" || font.family === "SF Pro Text"
|
|
141
|
+
return Object.assign(Object.assign(Object.assign({ fontFamily: font.family === "initial" || font.family === "SF Pro Text"
|
|
142
142
|
? undefined
|
|
143
|
-
: font.family, fontWeight: font.weight === "initial" ? undefined : font.weight, fontSize: size, color: getColor(color), textTransform: uppercase ? "uppercase" : "none", textAlign: textAlignment, textWrap: wrapText ? "wrap" : "nowrap" }, (isItalic ? { fontStyle: "italic" } : {}))
|
|
143
|
+
: font.family, fontWeight: font.weight === "initial" ? undefined : font.weight, fontSize: size, color: getColor(color), textTransform: uppercase ? "uppercase" : "none", textAlign: textAlignment, textWrap: wrapText ? "wrap" : "nowrap" }, (isItalic ? { fontStyle: "italic" } : {})), (lineHeight !== undefined ? { lineHeight } : {})), (letterSpacing !== undefined
|
|
144
|
+
? { letterSpacing: `${letterSpacing}px` }
|
|
145
|
+
: {}));
|
|
144
146
|
};
|
|
145
147
|
export const getVerticalAlignment = (alignment, padding = { top: 0, bottom: 0 }) => {
|
|
146
148
|
if (alignment === "bottom") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variablesCart.util.d.ts","sourceRoot":"","sources":["../../lib/variablesCart.util.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,sBAAsB,EACtB,6BAA6B,EAO9B,MAAM,kBAAkB,CAAA;AAEzB,eAAO,MAAM,2BAA2B;;cAM5B,MAAM;;0BAEI;YAChB,gBAAgB,CAAC,EAAE,MAAM,CAAA;YACzB,KAAK,EAAE,MAAM,CAAA;YACb,cAAc,CAAC,EAAE,MAAM,CAAA;SACxB,EAAE;;;;;;CAyBN,CAAA;AA4FD,eAAO,MAAM,6BAA6B,SAClC,MAAM,QACN,SAAS,GAAG,IAAI,YAUvB,CAAA;AAED,eAAO,MAAM,2BAA2B,SAChC,MAAM,QACN,SAAS,GAAG,IAAI,YAUvB,CAAA;
|
|
1
|
+
{"version":3,"file":"variablesCart.util.d.ts","sourceRoot":"","sources":["../../lib/variablesCart.util.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,sBAAsB,EACtB,6BAA6B,EAO9B,MAAM,kBAAkB,CAAA;AAEzB,eAAO,MAAM,2BAA2B;;cAM5B,MAAM;;0BAEI;YAChB,gBAAgB,CAAC,EAAE,MAAM,CAAA;YACzB,KAAK,EAAE,MAAM,CAAA;YACb,cAAc,CAAC,EAAE,MAAM,CAAA;SACxB,EAAE;;;;;;CAyBN,CAAA;AA4FD,eAAO,MAAM,6BAA6B,SAClC,MAAM,QACN,SAAS,GAAG,IAAI,YAUvB,CAAA;AAED,eAAO,MAAM,2BAA2B,SAChC,MAAM,QACN,SAAS,GAAG,IAAI,YAUvB,CAAA;AAqLD,MAAM,MAAM,uBAAuB,GAAG;IACpC,yBAAyB,EAAE,sBAAsB,EAAE,CAAA;IACnD,gBAAgB,EAAE,6BAA6B,EAAE,CAAA;IACjD,cAAc,EAAE,OAAO,CAAA;IACvB,oBAAoB,EAAE,MAAM,CAAA;IAC5B,oBAAoB,EAAE,MAAM,CAAA;IAC5B,WAAW,EAAE,MAAM,CAAA;IACnB,mBAAmB,EAAE,MAAM,CAAA;IAC3B,oBAAoB,EAAE,MAAM,CAAA;IAC5B,gBAAgB,EAAE,MAAM,CAAA;CACzB,CAAA;AAED,eAAO,MAAM,iCAAiC,EAAE,uBAU/C,CAAA;AAED,eAAO,MAAM,8BAA8B,SACnC,SAAS,GAAG,IAAI,KACrB,uBAmCF,CAAA"}
|
|
@@ -5,9 +5,9 @@ export const getSubscriptionPriceDetails = ({ totalAmount, quantity, sellingPlan
|
|
|
5
5
|
const isSubscription = ((_a = sellingPlanAllocation === null || sellingPlanAllocation === void 0 ? void 0 : sellingPlanAllocation.priceAdjustments) === null || _a === void 0 ? void 0 : _a.length) > 0;
|
|
6
6
|
if (isSubscription) {
|
|
7
7
|
const { perDeliveryPrice, price, compareAtPrice } = sellingPlanAllocation.priceAdjustments[0];
|
|
8
|
-
const effectivePrice = perDeliveryPrice || price;
|
|
9
|
-
const subscriptionUnitPrice = perDeliveryPrice || 0;
|
|
10
|
-
const effectiveCompareAtPrice = compareAtPrice * quantity || totalAmount || 0;
|
|
8
|
+
const effectivePrice = (perDeliveryPrice === null || perDeliveryPrice === void 0 ? void 0 : perDeliveryPrice.amount) || price.amount;
|
|
9
|
+
const subscriptionUnitPrice = (perDeliveryPrice === null || perDeliveryPrice === void 0 ? void 0 : perDeliveryPrice.amount) || 0;
|
|
10
|
+
const effectiveCompareAtPrice = (compareAtPrice === null || compareAtPrice === void 0 ? void 0 : compareAtPrice.amount) * quantity || totalAmount || 0;
|
|
11
11
|
return {
|
|
12
12
|
price: totalAmount,
|
|
13
13
|
compareAtPrice: effectiveCompareAtPrice,
|
|
@@ -133,7 +133,7 @@ const getCompareAtPriceDifference = (cart) => {
|
|
|
133
133
|
if (!cart)
|
|
134
134
|
return 0;
|
|
135
135
|
return (_a = cart === null || cart === void 0 ? void 0 : cart.items) === null || _a === void 0 ? void 0 : _a.reduce((acc, item) => {
|
|
136
|
-
var _a, _b, _c, _d, _e, _f;
|
|
136
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
137
137
|
/**
|
|
138
138
|
* Regular price details
|
|
139
139
|
*/
|
|
@@ -144,8 +144,8 @@ const getCompareAtPriceDifference = (cart) => {
|
|
|
144
144
|
*/
|
|
145
145
|
if (((_b = (_a = item === null || item === void 0 ? void 0 : item.sellingPlanAllocation) === null || _a === void 0 ? void 0 : _a.priceAdjustments) === null || _b === void 0 ? void 0 : _b.length) > 0) {
|
|
146
146
|
itemPrice =
|
|
147
|
-
((_d = (_c = item === null || item === void 0 ? void 0 : item.sellingPlanAllocation) === null || _c === void 0 ? void 0 : _c.priceAdjustments[0]) === null || _d === void 0 ? void 0 : _d.perDeliveryPrice) ||
|
|
148
|
-
((
|
|
147
|
+
((_e = (_d = (_c = item === null || item === void 0 ? void 0 : item.sellingPlanAllocation) === null || _c === void 0 ? void 0 : _c.priceAdjustments[0]) === null || _d === void 0 ? void 0 : _d.perDeliveryPrice) === null || _e === void 0 ? void 0 : _e.amount) ||
|
|
148
|
+
((_h = (_g = (_f = item === null || item === void 0 ? void 0 : item.sellingPlanAllocation) === null || _f === void 0 ? void 0 : _f.priceAdjustments[0]) === null || _g === void 0 ? void 0 : _g.price) === null || _h === void 0 ? void 0 : _h.amount) ||
|
|
149
149
|
0;
|
|
150
150
|
const { compareAtPrice } = getSubscriptionPriceDetails({
|
|
151
151
|
quantity: (item === null || item === void 0 ? void 0 : item.quantity) || 1,
|
|
@@ -574,9 +574,18 @@ describe("cart-provider.util", () => {
|
|
|
574
574
|
name: "Ski wax subscription, billed and delivered weekly",
|
|
575
575
|
priceAdjustments: [
|
|
576
576
|
{
|
|
577
|
-
compareAtPrice:
|
|
578
|
-
|
|
579
|
-
|
|
577
|
+
compareAtPrice: {
|
|
578
|
+
amount: 10,
|
|
579
|
+
currencyCode: "USD",
|
|
580
|
+
},
|
|
581
|
+
perDeliveryPrice: {
|
|
582
|
+
amount: 8.5,
|
|
583
|
+
currencyCode: "USD",
|
|
584
|
+
},
|
|
585
|
+
price: {
|
|
586
|
+
amount: 8.5,
|
|
587
|
+
currencyCode: "USD",
|
|
588
|
+
},
|
|
580
589
|
},
|
|
581
590
|
],
|
|
582
591
|
},
|
package/dist/styles.css
CHANGED
|
@@ -1429,6 +1429,9 @@ video {
|
|
|
1429
1429
|
.grid-cols-\[auto_1fr_auto\] {
|
|
1430
1430
|
grid-template-columns: auto 1fr auto;
|
|
1431
1431
|
}
|
|
1432
|
+
.grid-rows-2 {
|
|
1433
|
+
grid-template-rows: repeat(2, minmax(0, 1fr));
|
|
1434
|
+
}
|
|
1432
1435
|
.flex-row {
|
|
1433
1436
|
flex-direction: row;
|
|
1434
1437
|
}
|
|
@@ -1974,6 +1977,9 @@ video {
|
|
|
1974
1977
|
.pr-1 {
|
|
1975
1978
|
padding-right: 0.25rem;
|
|
1976
1979
|
}
|
|
1980
|
+
.pr-10 {
|
|
1981
|
+
padding-right: 2.5rem;
|
|
1982
|
+
}
|
|
1977
1983
|
.pr-2 {
|
|
1978
1984
|
padding-right: 0.5rem;
|
|
1979
1985
|
}
|
package/dist/tests/utils.test.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getDestinationHandler } from "../lib/utils";
|
|
1
|
+
import { getDestinationHandler, getTextStyle } from "../lib/utils";
|
|
2
2
|
describe("DESTINATION_HANDLERS", () => {
|
|
3
3
|
describe("url handler", () => {
|
|
4
4
|
const mockActions = {
|
|
@@ -32,3 +32,580 @@ describe("DESTINATION_HANDLERS", () => {
|
|
|
32
32
|
});
|
|
33
33
|
});
|
|
34
34
|
});
|
|
35
|
+
describe("getTextStyle", () => {
|
|
36
|
+
describe("basic functionality", () => {
|
|
37
|
+
it("should return correct CSS properties for basic text style", () => {
|
|
38
|
+
const textStyle = {
|
|
39
|
+
font: {
|
|
40
|
+
family: "Arial",
|
|
41
|
+
weight: 400,
|
|
42
|
+
},
|
|
43
|
+
size: 16,
|
|
44
|
+
color: { type: "custom", value: "#000000" },
|
|
45
|
+
uppercase: false,
|
|
46
|
+
textAlignment: "left",
|
|
47
|
+
wrapText: true,
|
|
48
|
+
};
|
|
49
|
+
const result = getTextStyle(textStyle);
|
|
50
|
+
expect(result).toEqual({
|
|
51
|
+
fontFamily: "Arial",
|
|
52
|
+
fontWeight: 400,
|
|
53
|
+
fontSize: 16,
|
|
54
|
+
color: "#000000",
|
|
55
|
+
textTransform: "none",
|
|
56
|
+
textAlign: "left",
|
|
57
|
+
textWrap: "wrap",
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
it("should handle all text alignment options", () => {
|
|
61
|
+
const alignments = ["left", "center", "right", "justify"];
|
|
62
|
+
alignments.forEach((alignment) => {
|
|
63
|
+
const textStyle = {
|
|
64
|
+
font: { family: "Arial", weight: 400 },
|
|
65
|
+
size: 16,
|
|
66
|
+
color: { type: "custom", value: "#000000" },
|
|
67
|
+
uppercase: false,
|
|
68
|
+
textAlignment: alignment,
|
|
69
|
+
wrapText: true,
|
|
70
|
+
};
|
|
71
|
+
const result = getTextStyle(textStyle);
|
|
72
|
+
expect(result.textAlign).toBe(alignment);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
describe("font family handling", () => {
|
|
77
|
+
it("should return undefined for 'initial' font family", () => {
|
|
78
|
+
const textStyle = {
|
|
79
|
+
font: {
|
|
80
|
+
family: "initial",
|
|
81
|
+
weight: 400,
|
|
82
|
+
},
|
|
83
|
+
size: 16,
|
|
84
|
+
color: { type: "custom", value: "#000000" },
|
|
85
|
+
uppercase: false,
|
|
86
|
+
textAlignment: "left",
|
|
87
|
+
wrapText: true,
|
|
88
|
+
};
|
|
89
|
+
const result = getTextStyle(textStyle);
|
|
90
|
+
expect(result.fontFamily).toBeUndefined();
|
|
91
|
+
});
|
|
92
|
+
it("should return undefined for 'SF Pro Text' font family", () => {
|
|
93
|
+
const textStyle = {
|
|
94
|
+
font: {
|
|
95
|
+
family: "SF Pro Text",
|
|
96
|
+
weight: 400,
|
|
97
|
+
},
|
|
98
|
+
size: 16,
|
|
99
|
+
color: { type: "custom", value: "#000000" },
|
|
100
|
+
uppercase: false,
|
|
101
|
+
textAlignment: "left",
|
|
102
|
+
wrapText: true,
|
|
103
|
+
};
|
|
104
|
+
const result = getTextStyle(textStyle);
|
|
105
|
+
expect(result.fontFamily).toBeUndefined();
|
|
106
|
+
});
|
|
107
|
+
it("should handle custom font families", () => {
|
|
108
|
+
const textStyle = {
|
|
109
|
+
font: {
|
|
110
|
+
family: "Helvetica Neue",
|
|
111
|
+
weight: 400,
|
|
112
|
+
},
|
|
113
|
+
size: 16,
|
|
114
|
+
color: { type: "custom", value: "#000000" },
|
|
115
|
+
uppercase: false,
|
|
116
|
+
textAlignment: "left",
|
|
117
|
+
wrapText: true,
|
|
118
|
+
};
|
|
119
|
+
const result = getTextStyle(textStyle);
|
|
120
|
+
expect(result.fontFamily).toBe("Helvetica Neue");
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
describe("font weight handling", () => {
|
|
124
|
+
it("should return undefined for 'initial' font weight", () => {
|
|
125
|
+
const textStyle = {
|
|
126
|
+
font: {
|
|
127
|
+
family: "Arial",
|
|
128
|
+
weight: "initial",
|
|
129
|
+
},
|
|
130
|
+
size: 16,
|
|
131
|
+
color: { type: "custom", value: "#000000" },
|
|
132
|
+
uppercase: false,
|
|
133
|
+
textAlignment: "left",
|
|
134
|
+
wrapText: true,
|
|
135
|
+
};
|
|
136
|
+
const result = getTextStyle(textStyle);
|
|
137
|
+
expect(result.fontWeight).toBeUndefined();
|
|
138
|
+
});
|
|
139
|
+
it("should handle numeric font weights", () => {
|
|
140
|
+
const weights = [100, 200, 300, 400, 500, 600, 700, 800, 900];
|
|
141
|
+
weights.forEach((weight) => {
|
|
142
|
+
const textStyle = {
|
|
143
|
+
font: { family: "Arial", weight },
|
|
144
|
+
size: 16,
|
|
145
|
+
color: { type: "custom", value: "#000000" },
|
|
146
|
+
uppercase: false,
|
|
147
|
+
textAlignment: "left",
|
|
148
|
+
wrapText: true,
|
|
149
|
+
};
|
|
150
|
+
const result = getTextStyle(textStyle);
|
|
151
|
+
expect(result.fontWeight).toBe(weight);
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
it("should handle string font weights", () => {
|
|
155
|
+
const textStyle = {
|
|
156
|
+
font: {
|
|
157
|
+
family: "Arial",
|
|
158
|
+
weight: "bold",
|
|
159
|
+
},
|
|
160
|
+
size: 16,
|
|
161
|
+
color: { type: "custom", value: "#000000" },
|
|
162
|
+
uppercase: false,
|
|
163
|
+
textAlignment: "left",
|
|
164
|
+
wrapText: true,
|
|
165
|
+
};
|
|
166
|
+
const result = getTextStyle(textStyle);
|
|
167
|
+
expect(result.fontWeight).toBe("bold");
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
describe("italic detection", () => {
|
|
171
|
+
it("should detect italic in font family name (lowercase)", () => {
|
|
172
|
+
const textStyle = {
|
|
173
|
+
font: {
|
|
174
|
+
family: "Arial Italic",
|
|
175
|
+
weight: 400,
|
|
176
|
+
},
|
|
177
|
+
size: 16,
|
|
178
|
+
color: { type: "custom", value: "#000000" },
|
|
179
|
+
uppercase: false,
|
|
180
|
+
textAlignment: "left",
|
|
181
|
+
wrapText: true,
|
|
182
|
+
};
|
|
183
|
+
const result = getTextStyle(textStyle);
|
|
184
|
+
expect(result.fontStyle).toBe("italic");
|
|
185
|
+
});
|
|
186
|
+
it("should detect italic in font family name (mixed case)", () => {
|
|
187
|
+
const textStyle = {
|
|
188
|
+
font: {
|
|
189
|
+
family: "Helvetica-Italic",
|
|
190
|
+
weight: 400,
|
|
191
|
+
},
|
|
192
|
+
size: 16,
|
|
193
|
+
color: { type: "custom", value: "#000000" },
|
|
194
|
+
uppercase: false,
|
|
195
|
+
textAlignment: "left",
|
|
196
|
+
wrapText: true,
|
|
197
|
+
};
|
|
198
|
+
const result = getTextStyle(textStyle);
|
|
199
|
+
expect(result.fontStyle).toBe("italic");
|
|
200
|
+
});
|
|
201
|
+
it("should detect italic in font family name (uppercase)", () => {
|
|
202
|
+
const textStyle = {
|
|
203
|
+
font: {
|
|
204
|
+
family: "Times New Roman ITALIC",
|
|
205
|
+
weight: 400,
|
|
206
|
+
},
|
|
207
|
+
size: 16,
|
|
208
|
+
color: { type: "custom", value: "#000000" },
|
|
209
|
+
uppercase: false,
|
|
210
|
+
textAlignment: "left",
|
|
211
|
+
wrapText: true,
|
|
212
|
+
};
|
|
213
|
+
const result = getTextStyle(textStyle);
|
|
214
|
+
expect(result.fontStyle).toBe("italic");
|
|
215
|
+
});
|
|
216
|
+
it("should not add fontStyle when italic is not in font family name", () => {
|
|
217
|
+
const textStyle = {
|
|
218
|
+
font: {
|
|
219
|
+
family: "Arial Bold",
|
|
220
|
+
weight: 400,
|
|
221
|
+
},
|
|
222
|
+
size: 16,
|
|
223
|
+
color: { type: "custom", value: "#000000" },
|
|
224
|
+
uppercase: false,
|
|
225
|
+
textAlignment: "left",
|
|
226
|
+
wrapText: true,
|
|
227
|
+
};
|
|
228
|
+
const result = getTextStyle(textStyle);
|
|
229
|
+
expect(result.fontStyle).toBeUndefined();
|
|
230
|
+
});
|
|
231
|
+
it("should handle non-string font family", () => {
|
|
232
|
+
const textStyle = {
|
|
233
|
+
font: {
|
|
234
|
+
family: null,
|
|
235
|
+
weight: 400,
|
|
236
|
+
},
|
|
237
|
+
size: 16,
|
|
238
|
+
color: { type: "custom", value: "#000000" },
|
|
239
|
+
uppercase: false,
|
|
240
|
+
textAlignment: "left",
|
|
241
|
+
wrapText: true,
|
|
242
|
+
};
|
|
243
|
+
const result = getTextStyle(textStyle);
|
|
244
|
+
expect(result.fontStyle).toBeUndefined();
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
describe("text transformation", () => {
|
|
248
|
+
it("should apply uppercase transformation when uppercase is true", () => {
|
|
249
|
+
const textStyle = {
|
|
250
|
+
font: { family: "Arial", weight: 400 },
|
|
251
|
+
size: 16,
|
|
252
|
+
color: { type: "custom", value: "#000000" },
|
|
253
|
+
uppercase: true,
|
|
254
|
+
textAlignment: "left",
|
|
255
|
+
wrapText: true,
|
|
256
|
+
};
|
|
257
|
+
const result = getTextStyle(textStyle);
|
|
258
|
+
expect(result.textTransform).toBe("uppercase");
|
|
259
|
+
});
|
|
260
|
+
it("should apply none transformation when uppercase is false", () => {
|
|
261
|
+
const textStyle = {
|
|
262
|
+
font: { family: "Arial", weight: 400 },
|
|
263
|
+
size: 16,
|
|
264
|
+
color: { type: "custom", value: "#000000" },
|
|
265
|
+
uppercase: false,
|
|
266
|
+
textAlignment: "left",
|
|
267
|
+
wrapText: true,
|
|
268
|
+
};
|
|
269
|
+
const result = getTextStyle(textStyle);
|
|
270
|
+
expect(result.textTransform).toBe("none");
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
describe("text wrapping", () => {
|
|
274
|
+
it("should set textWrap to 'wrap' when wrapText is true", () => {
|
|
275
|
+
const textStyle = {
|
|
276
|
+
font: { family: "Arial", weight: 400 },
|
|
277
|
+
size: 16,
|
|
278
|
+
color: { type: "custom", value: "#000000" },
|
|
279
|
+
uppercase: false,
|
|
280
|
+
textAlignment: "left",
|
|
281
|
+
wrapText: true,
|
|
282
|
+
};
|
|
283
|
+
const result = getTextStyle(textStyle);
|
|
284
|
+
expect(result.textWrap).toBe("wrap");
|
|
285
|
+
});
|
|
286
|
+
it("should set textWrap to 'nowrap' when wrapText is false", () => {
|
|
287
|
+
const textStyle = {
|
|
288
|
+
font: { family: "Arial", weight: 400 },
|
|
289
|
+
size: 16,
|
|
290
|
+
color: { type: "custom", value: "#000000" },
|
|
291
|
+
uppercase: false,
|
|
292
|
+
textAlignment: "left",
|
|
293
|
+
wrapText: false,
|
|
294
|
+
};
|
|
295
|
+
const result = getTextStyle(textStyle);
|
|
296
|
+
expect(result.textWrap).toBe("nowrap");
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
describe("color handling", () => {
|
|
300
|
+
it("should handle custom colors", () => {
|
|
301
|
+
const customColor = { type: "custom", value: "#ff0000" };
|
|
302
|
+
const textStyle = {
|
|
303
|
+
font: { family: "Arial", weight: 400 },
|
|
304
|
+
size: 16,
|
|
305
|
+
color: customColor,
|
|
306
|
+
uppercase: false,
|
|
307
|
+
textAlignment: "left",
|
|
308
|
+
wrapText: true,
|
|
309
|
+
};
|
|
310
|
+
const result = getTextStyle(textStyle);
|
|
311
|
+
expect(result.color).toBe("#ff0000"); // getColor returns the value for custom colors
|
|
312
|
+
});
|
|
313
|
+
it("should handle brand-kit colors", () => {
|
|
314
|
+
const brandColor = { type: "brand-kit", value: "primary" };
|
|
315
|
+
const textStyle = {
|
|
316
|
+
font: { family: "Arial", weight: 400 },
|
|
317
|
+
size: 16,
|
|
318
|
+
color: brandColor,
|
|
319
|
+
uppercase: false,
|
|
320
|
+
textAlignment: "left",
|
|
321
|
+
wrapText: true,
|
|
322
|
+
};
|
|
323
|
+
const result = getTextStyle(textStyle);
|
|
324
|
+
expect(result.color).toBe("var(--primary)"); // getColor returns var(--value) for brand-kit colors
|
|
325
|
+
});
|
|
326
|
+
it("should handle undefined color", () => {
|
|
327
|
+
const textStyle = {
|
|
328
|
+
font: { family: "Arial", weight: 400 },
|
|
329
|
+
size: 16,
|
|
330
|
+
color: undefined,
|
|
331
|
+
uppercase: false,
|
|
332
|
+
textAlignment: "left",
|
|
333
|
+
wrapText: true,
|
|
334
|
+
};
|
|
335
|
+
const result = getTextStyle(textStyle);
|
|
336
|
+
expect(result.color).toBeUndefined(); // getColor returns undefined for undefined input
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
describe("font size handling", () => {
|
|
340
|
+
it("should handle numeric font sizes", () => {
|
|
341
|
+
const textStyle = {
|
|
342
|
+
font: { family: "Arial", weight: 400 },
|
|
343
|
+
size: 24,
|
|
344
|
+
color: { type: "custom", value: "#000000" },
|
|
345
|
+
uppercase: false,
|
|
346
|
+
textAlignment: "left",
|
|
347
|
+
wrapText: true,
|
|
348
|
+
};
|
|
349
|
+
const result = getTextStyle(textStyle);
|
|
350
|
+
expect(result.fontSize).toBe(24);
|
|
351
|
+
});
|
|
352
|
+
it("should handle string font sizes", () => {
|
|
353
|
+
const textStyle = {
|
|
354
|
+
font: { family: "Arial", weight: 400 },
|
|
355
|
+
size: "1.5rem",
|
|
356
|
+
color: { type: "custom", value: "#000000" },
|
|
357
|
+
uppercase: false,
|
|
358
|
+
textAlignment: "left",
|
|
359
|
+
wrapText: true,
|
|
360
|
+
};
|
|
361
|
+
const result = getTextStyle(textStyle);
|
|
362
|
+
expect(result.fontSize).toBe("1.5rem");
|
|
363
|
+
});
|
|
364
|
+
});
|
|
365
|
+
describe("line height handling", () => {
|
|
366
|
+
it("should include lineHeight when defined", () => {
|
|
367
|
+
const textStyle = {
|
|
368
|
+
font: { family: "Arial", weight: 400 },
|
|
369
|
+
size: 16,
|
|
370
|
+
color: { type: "custom", value: "#000000" },
|
|
371
|
+
uppercase: false,
|
|
372
|
+
textAlignment: "left",
|
|
373
|
+
wrapText: true,
|
|
374
|
+
lineHeight: 1.5,
|
|
375
|
+
};
|
|
376
|
+
const result = getTextStyle(textStyle);
|
|
377
|
+
expect(result.lineHeight).toBe(1.5);
|
|
378
|
+
});
|
|
379
|
+
it("should not include lineHeight when undefined", () => {
|
|
380
|
+
const textStyle = {
|
|
381
|
+
font: { family: "Arial", weight: 400 },
|
|
382
|
+
size: 16,
|
|
383
|
+
color: { type: "custom", value: "#000000" },
|
|
384
|
+
uppercase: false,
|
|
385
|
+
textAlignment: "left",
|
|
386
|
+
wrapText: true,
|
|
387
|
+
};
|
|
388
|
+
const result = getTextStyle(textStyle);
|
|
389
|
+
expect(result.lineHeight).toBeUndefined();
|
|
390
|
+
});
|
|
391
|
+
it("should handle lineHeight value of 0", () => {
|
|
392
|
+
const textStyle = {
|
|
393
|
+
font: { family: "Arial", weight: 400 },
|
|
394
|
+
size: 16,
|
|
395
|
+
color: { type: "custom", value: "#000000" },
|
|
396
|
+
uppercase: false,
|
|
397
|
+
textAlignment: "left",
|
|
398
|
+
wrapText: true,
|
|
399
|
+
lineHeight: 0,
|
|
400
|
+
};
|
|
401
|
+
const result = getTextStyle(textStyle);
|
|
402
|
+
expect(result.lineHeight).toBe(0);
|
|
403
|
+
});
|
|
404
|
+
it("should handle decimal lineHeight values", () => {
|
|
405
|
+
const textStyle = {
|
|
406
|
+
font: { family: "Arial", weight: 400 },
|
|
407
|
+
size: 16,
|
|
408
|
+
color: { type: "custom", value: "#000000" },
|
|
409
|
+
uppercase: false,
|
|
410
|
+
textAlignment: "left",
|
|
411
|
+
wrapText: true,
|
|
412
|
+
lineHeight: 2.25,
|
|
413
|
+
};
|
|
414
|
+
const result = getTextStyle(textStyle);
|
|
415
|
+
expect(result.lineHeight).toBe(2.25);
|
|
416
|
+
});
|
|
417
|
+
});
|
|
418
|
+
describe("letter spacing handling", () => {
|
|
419
|
+
it("should include letterSpacing when defined", () => {
|
|
420
|
+
const textStyle = {
|
|
421
|
+
font: { family: "Arial", weight: 400 },
|
|
422
|
+
size: 16,
|
|
423
|
+
color: { type: "custom", value: "#000000" },
|
|
424
|
+
uppercase: false,
|
|
425
|
+
textAlignment: "left",
|
|
426
|
+
wrapText: true,
|
|
427
|
+
letterSpacing: 0.5,
|
|
428
|
+
};
|
|
429
|
+
const result = getTextStyle(textStyle);
|
|
430
|
+
expect(result.letterSpacing).toBe("0.5px");
|
|
431
|
+
});
|
|
432
|
+
it("should not include letterSpacing when undefined", () => {
|
|
433
|
+
const textStyle = {
|
|
434
|
+
font: { family: "Arial", weight: 400 },
|
|
435
|
+
size: 16,
|
|
436
|
+
color: { type: "custom", value: "#000000" },
|
|
437
|
+
uppercase: false,
|
|
438
|
+
textAlignment: "left",
|
|
439
|
+
wrapText: true,
|
|
440
|
+
};
|
|
441
|
+
const result = getTextStyle(textStyle);
|
|
442
|
+
expect(result.letterSpacing).toBeUndefined();
|
|
443
|
+
});
|
|
444
|
+
it("should handle letterSpacing value of 0", () => {
|
|
445
|
+
const textStyle = {
|
|
446
|
+
font: { family: "Arial", weight: 400 },
|
|
447
|
+
size: 16,
|
|
448
|
+
color: { type: "custom", value: "#000000" },
|
|
449
|
+
uppercase: false,
|
|
450
|
+
textAlignment: "left",
|
|
451
|
+
wrapText: true,
|
|
452
|
+
letterSpacing: 0,
|
|
453
|
+
};
|
|
454
|
+
const result = getTextStyle(textStyle);
|
|
455
|
+
expect(result.letterSpacing).toBe("0px");
|
|
456
|
+
});
|
|
457
|
+
it("should handle negative letterSpacing values", () => {
|
|
458
|
+
const textStyle = {
|
|
459
|
+
font: { family: "Arial", weight: 400 },
|
|
460
|
+
size: 16,
|
|
461
|
+
color: { type: "custom", value: "#000000" },
|
|
462
|
+
uppercase: false,
|
|
463
|
+
textAlignment: "left",
|
|
464
|
+
wrapText: true,
|
|
465
|
+
letterSpacing: -0.25,
|
|
466
|
+
};
|
|
467
|
+
const result = getTextStyle(textStyle);
|
|
468
|
+
expect(result.letterSpacing).toBe("-0.25px");
|
|
469
|
+
});
|
|
470
|
+
it("should handle decimal letterSpacing values", () => {
|
|
471
|
+
const textStyle = {
|
|
472
|
+
font: { family: "Arial", weight: 400 },
|
|
473
|
+
size: 16,
|
|
474
|
+
color: { type: "custom", value: "#000000" },
|
|
475
|
+
uppercase: false,
|
|
476
|
+
textAlignment: "left",
|
|
477
|
+
wrapText: true,
|
|
478
|
+
letterSpacing: 1.75,
|
|
479
|
+
};
|
|
480
|
+
const result = getTextStyle(textStyle);
|
|
481
|
+
expect(result.letterSpacing).toBe("1.75px");
|
|
482
|
+
});
|
|
483
|
+
it("should handle integer letterSpacing values", () => {
|
|
484
|
+
const textStyle = {
|
|
485
|
+
font: { family: "Arial", weight: 400 },
|
|
486
|
+
size: 16,
|
|
487
|
+
color: { type: "custom", value: "#000000" },
|
|
488
|
+
uppercase: false,
|
|
489
|
+
textAlignment: "left",
|
|
490
|
+
wrapText: true,
|
|
491
|
+
letterSpacing: 2,
|
|
492
|
+
};
|
|
493
|
+
const result = getTextStyle(textStyle);
|
|
494
|
+
expect(result.letterSpacing).toBe("2px");
|
|
495
|
+
});
|
|
496
|
+
});
|
|
497
|
+
describe("combined line height and letter spacing", () => {
|
|
498
|
+
it("should include both lineHeight and letterSpacing when both are defined", () => {
|
|
499
|
+
const textStyle = {
|
|
500
|
+
font: { family: "Arial", weight: 400 },
|
|
501
|
+
size: 16,
|
|
502
|
+
color: { type: "custom", value: "#000000" },
|
|
503
|
+
uppercase: false,
|
|
504
|
+
textAlignment: "left",
|
|
505
|
+
wrapText: true,
|
|
506
|
+
lineHeight: 1.6,
|
|
507
|
+
letterSpacing: 0.8,
|
|
508
|
+
};
|
|
509
|
+
const result = getTextStyle(textStyle);
|
|
510
|
+
expect(result.lineHeight).toBe(1.6);
|
|
511
|
+
expect(result.letterSpacing).toBe("0.8px");
|
|
512
|
+
});
|
|
513
|
+
it("should include only lineHeight when letterSpacing is undefined", () => {
|
|
514
|
+
const textStyle = {
|
|
515
|
+
font: { family: "Arial", weight: 400 },
|
|
516
|
+
size: 16,
|
|
517
|
+
color: { type: "custom", value: "#000000" },
|
|
518
|
+
uppercase: false,
|
|
519
|
+
textAlignment: "left",
|
|
520
|
+
wrapText: true,
|
|
521
|
+
lineHeight: 2.0,
|
|
522
|
+
};
|
|
523
|
+
const result = getTextStyle(textStyle);
|
|
524
|
+
expect(result.lineHeight).toBe(2.0);
|
|
525
|
+
expect(result.letterSpacing).toBeUndefined();
|
|
526
|
+
});
|
|
527
|
+
it("should include only letterSpacing when lineHeight is undefined", () => {
|
|
528
|
+
const textStyle = {
|
|
529
|
+
font: { family: "Arial", weight: 400 },
|
|
530
|
+
size: 16,
|
|
531
|
+
color: { type: "custom", value: "#000000" },
|
|
532
|
+
uppercase: false,
|
|
533
|
+
textAlignment: "left",
|
|
534
|
+
wrapText: true,
|
|
535
|
+
letterSpacing: -0.1,
|
|
536
|
+
};
|
|
537
|
+
const result = getTextStyle(textStyle);
|
|
538
|
+
expect(result.lineHeight).toBeUndefined();
|
|
539
|
+
expect(result.letterSpacing).toBe("-0.1px");
|
|
540
|
+
});
|
|
541
|
+
});
|
|
542
|
+
describe("edge cases and complex scenarios", () => {
|
|
543
|
+
it("should handle all special values together", () => {
|
|
544
|
+
const textStyle = {
|
|
545
|
+
font: {
|
|
546
|
+
family: "initial",
|
|
547
|
+
weight: "initial",
|
|
548
|
+
},
|
|
549
|
+
size: 16,
|
|
550
|
+
color: { type: "custom", value: "#000000" },
|
|
551
|
+
uppercase: true,
|
|
552
|
+
textAlignment: "center",
|
|
553
|
+
wrapText: false,
|
|
554
|
+
};
|
|
555
|
+
const result = getTextStyle(textStyle);
|
|
556
|
+
expect(result).toEqual({
|
|
557
|
+
fontFamily: undefined,
|
|
558
|
+
fontWeight: undefined,
|
|
559
|
+
fontSize: 16,
|
|
560
|
+
color: "#000000",
|
|
561
|
+
textTransform: "uppercase",
|
|
562
|
+
textAlign: "center",
|
|
563
|
+
textWrap: "nowrap",
|
|
564
|
+
});
|
|
565
|
+
});
|
|
566
|
+
it("should handle italic font with special font family", () => {
|
|
567
|
+
const textStyle = {
|
|
568
|
+
font: {
|
|
569
|
+
family: "SF Pro Text Italic",
|
|
570
|
+
weight: 600,
|
|
571
|
+
},
|
|
572
|
+
size: 18,
|
|
573
|
+
color: { type: "brand-kit", value: "secondary" },
|
|
574
|
+
uppercase: true,
|
|
575
|
+
textAlignment: "right",
|
|
576
|
+
wrapText: true,
|
|
577
|
+
lineHeight: 1.4,
|
|
578
|
+
letterSpacing: 0.2,
|
|
579
|
+
};
|
|
580
|
+
const result = getTextStyle(textStyle);
|
|
581
|
+
expect(result).toEqual({
|
|
582
|
+
fontFamily: "SF Pro Text Italic",
|
|
583
|
+
fontWeight: 600,
|
|
584
|
+
fontSize: 18,
|
|
585
|
+
color: "var(--secondary)",
|
|
586
|
+
textTransform: "uppercase",
|
|
587
|
+
textAlign: "right",
|
|
588
|
+
textWrap: "wrap",
|
|
589
|
+
fontStyle: "italic",
|
|
590
|
+
lineHeight: 1.4,
|
|
591
|
+
letterSpacing: "0.2px",
|
|
592
|
+
});
|
|
593
|
+
});
|
|
594
|
+
it("should handle empty/null font family gracefully", () => {
|
|
595
|
+
const textStyle = {
|
|
596
|
+
font: {
|
|
597
|
+
family: "",
|
|
598
|
+
weight: 400,
|
|
599
|
+
},
|
|
600
|
+
size: 16,
|
|
601
|
+
color: { type: "custom", value: "#000000" },
|
|
602
|
+
uppercase: false,
|
|
603
|
+
textAlignment: "left",
|
|
604
|
+
wrapText: true,
|
|
605
|
+
};
|
|
606
|
+
const result = getTextStyle(textStyle);
|
|
607
|
+
expect(result.fontFamily).toBe("");
|
|
608
|
+
expect(result.fontStyle).toBeUndefined();
|
|
609
|
+
});
|
|
610
|
+
});
|
|
611
|
+
});
|