linkedunion-design-kit 1.5.0 → 1.5.2
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/.next/types/app/page.js +17 -7
- package/dist/components/Avatar/Avatar.js +1 -1
- package/dist/components/Avatar/Avatar.stories.d.ts +1 -1
- package/dist/components/Avatar/Avatar.stories.js +4 -4
- package/dist/components/Avatar/Avatar.test.d.ts +1 -0
- package/dist/components/Avatar/Avatar.test.js +54 -0
- package/dist/components/Border/BorderRadius/BorderRadius.stories.d.ts +1 -1
- package/dist/components/Border/BorderRadius/BorderRadius.stories.js +4 -4
- package/dist/components/Border/BorderRadius/BorderRadius.test.d.ts +1 -0
- package/dist/components/Border/BorderRadius/BorderRadius.test.js +25 -0
- package/dist/components/Border/BorderWidth/BorderWidth.stories.d.ts +1 -1
- package/dist/components/Border/BorderWidth/BorderWidth.stories.js +4 -4
- package/dist/components/Border/BorderWidth/BorderWidth.test.d.ts +1 -0
- package/dist/components/Border/BorderWidth/BorderWidth.test.js +25 -0
- package/dist/components/Button/Button.js +5 -5
- package/dist/components/Button/Button.stories.d.ts +1 -1
- package/dist/components/Button/Button.stories.js +8 -8
- package/dist/components/Button/Button.test.d.ts +1 -0
- package/dist/components/Button/Button.test.js +54 -0
- package/dist/components/Button/index.js +0 -1
- package/dist/components/Color/BackgroundColor/BackgroundColor.js +7 -3
- package/dist/components/Color/BackgroundColor/BackgroundColor.stories.d.ts +6 -6
- package/dist/components/Color/BackgroundColor/BackgroundColor.stories.js +33 -30
- package/dist/components/Color/BackgroundColor/BackgroundColor.test.d.ts +1 -0
- package/dist/components/Color/BackgroundColor/BackgroundColor.test.js +17 -0
- package/dist/components/Color/Color.test.d.ts +1 -0
- package/dist/components/Color/Color.test.js +38 -0
- package/dist/components/Color/TextColor/TextColor.js +7 -3
- package/dist/components/Color/TextColor/TextColor.stories.d.ts +1 -1
- package/dist/components/Color/TextColor/TextColor.stories.js +14 -11
- package/dist/components/Color/TextColor/TextColor.test.d.ts +1 -0
- package/dist/components/Color/TextColor/TextColor.test.js +43 -0
- package/dist/components/Icons/IconList.test.d.ts +1 -0
- package/dist/components/Icons/IconList.test.js +60 -0
- package/dist/components/Icons/IconView.js +1 -1
- package/dist/components/Icons/IconView.stories.d.ts +1 -1
- package/dist/components/Icons/IconView.stories.js +2 -2
- package/dist/components/Icons/LUIcon.js +1 -1
- package/dist/components/Icons/LUIcon.stories.d.ts +1 -1
- package/dist/components/Icons/LUIcon.stories.js +4 -4
- package/dist/components/Icons/SingleIcon.test.d.ts +1 -0
- package/dist/components/Icons/SingleIcon.test.js +53 -0
- package/dist/components/Images/LuImage.js +1 -1
- package/dist/components/Images/LuImage.stories.d.ts +1 -1
- package/dist/components/Images/LuImage.stories.js +11 -10
- package/dist/components/Images/LuImage.test.d.ts +1 -0
- package/dist/components/Images/LuImage.test.js +68 -0
- package/dist/components/MediaCard/Card.js +3 -3
- package/dist/components/MediaCard/Card.stories.d.ts +1 -1
- package/dist/components/MediaCard/Card.stories.js +4 -4
- package/dist/components/MediaCard/Card.test.d.ts +1 -0
- package/dist/components/MediaCard/Card.test.js +33 -0
- package/dist/components/MediaCard/ContactProfile/ContactProfile.test.d.ts +1 -0
- package/dist/components/MediaCard/ContactProfile/ContactProfile.test.js +57 -0
- package/dist/components/MediaCard/ContactProfile/ContactProfileTheme1.js +1 -1
- package/dist/components/MediaCard/ContactProfile/ContactProfileTheme1.test.d.ts +1 -0
- package/dist/components/MediaCard/ContactProfile/ContactProfileTheme1.test.js +122 -0
- package/dist/components/MediaCard/ContactProfile/ContactProfileTheme2.js +1 -1
- package/dist/components/MediaCard/ContactProfile/ContactProfileTheme2.test.d.ts +1 -0
- package/dist/components/MediaCard/ContactProfile/ContactProfileTheme2.test.js +122 -0
- package/dist/components/MediaCard/PostByCategory/PostByCategory.js +1 -1
- package/dist/components/MediaCard/PostByCategory/PostByCategory.test.d.ts +1 -0
- package/dist/components/MediaCard/PostByCategory/PostByCategory.test.js +57 -0
- package/dist/components/MediaCard/PostByCategory/PostByCategoryTheme1.js +1 -1
- package/dist/components/MediaCard/PostByCategory/PostByCategoryTheme1.test.d.ts +1 -0
- package/dist/components/MediaCard/PostByCategory/PostByCategoryTheme1.test.js +122 -0
- package/dist/components/MediaCard/PostByCategory/PostByCategoryTheme2.js +1 -1
- package/dist/components/MediaCard/PostByCategory/PostByCategoryTheme2.test.d.ts +1 -0
- package/dist/components/MediaCard/PostByCategory/PostByCategoryTheme2.test.js +122 -0
- package/dist/components/MediaCard/index.js +0 -1
- package/dist/components/Size/MinWidthHeight.d.ts +1 -1
- package/dist/components/Size/MinWidthHeight.stories.d.ts +1 -1
- package/dist/components/Size/MinWidthHeight.stories.js +4 -4
- package/dist/components/Size/MinWidthHeight.test.d.ts +1 -0
- package/dist/components/Size/MinWidthHeight.test.js +34 -0
- package/dist/components/Size/Size.d.ts +3 -2
- package/dist/components/Size/Size.js +5 -3
- package/dist/components/Size/Size.stories.d.ts +3 -2
- package/dist/components/Size/Size.stories.js +3 -6
- package/dist/components/Size/Size.test.d.ts +1 -0
- package/dist/components/Size/Size.test.js +73 -0
- package/dist/components/Size/WidthAndHeight.test.d.ts +1 -0
- package/dist/components/Size/WidthAndHeight.test.js +34 -0
- package/dist/components/Size/WidthHeight.stories.d.ts +1 -1
- package/dist/components/Size/WidthHeight.stories.js +4 -4
- package/dist/components/Spacing/Margin/MarginToken.stories.d.ts +1 -1
- package/dist/components/Spacing/Margin/MarginToken.stories.js +2 -2
- package/dist/components/Spacing/Margin/MarginToken.test.d.ts +1 -0
- package/dist/components/Spacing/Margin/MarginToken.test.js +22 -0
- package/dist/components/Spacing/Padding/PaddingToken.stories.d.ts +1 -1
- package/dist/components/Spacing/Padding/PaddingToken.stories.js +2 -2
- package/dist/components/Spacing/Padding/PaddingToken.test.d.ts +1 -0
- package/dist/components/Spacing/Padding/PaddingToken.test.js +22 -0
- package/dist/components/Title/Title.d.ts +1 -1
- package/dist/components/Title/Title.stories.d.ts +1 -1
- package/dist/components/Title/Title.test.js +7 -6
- package/dist/components/Typography/Body/Body.stories.d.ts +1 -1
- package/dist/components/Typography/Body/body.test.js +24 -19
- package/dist/components/Typography/Display/Display.stories.d.ts +1 -1
- package/dist/components/Typography/Display/Display.test.js +24 -19
- package/dist/components/Typography/Headings/Headings.stories.d.ts +1 -1
- package/dist/components/Typography/Typography.css +16 -2
- package/dist/components/Typography/Typography.js +1 -1
- package/dist/components/Typography/Typography.stories.d.ts +1 -1
- package/dist/components/Typography/Typography.test.d.ts +1 -0
- package/dist/components/Typography/Typography.test.js +42 -0
- package/dist/global/components/Table/Table.d.ts +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/jest.config.d.ts +1 -0
- package/dist/jest.config.js +33 -0
- package/dist/jest.setup.d.ts +4 -0
- package/dist/jest.setup.js +35 -0
- package/dist/styles/global.css +16 -2
- package/dist/tailwind.config.js +14 -15
- package/dist/utils/iconList.js +8 -8
- package/dist/utils/index.d.ts +8 -8
- package/dist/utils/index.js +15 -19
- package/package.json +40 -14
- package/dist/components/Color/BackgroundColor/Color.d.ts +0 -2
- package/dist/components/Color/BackgroundColor/Color.js +0 -9
- package/dist/components/Color/BackgroundColor/Color.stories.d.ts +0 -10
- package/dist/components/Color/BackgroundColor/Color.stories.js +0 -103
- package/dist/components/Color/TextColor.d.ts +0 -3
- package/dist/components/Color/TextColor.js +0 -9
- package/dist/components/Color/TextColor.stories.d.ts +0 -6
- package/dist/components/Color/TextColor.stories.js +0 -35
- package/dist/components/Images/index.d.ts +0 -4
- package/dist/components/Images/index.js +0 -6
- package/dist/utils/enum.d.ts +0 -25
- package/dist/utils/enum.js +0 -25
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
15
|
+
var react_1 = require("@testing-library/react");
|
|
16
|
+
var ContactProfile_1 = require("./ContactProfile");
|
|
17
|
+
var enums_1 = require("../../../utils/enums");
|
|
18
|
+
var mockProps = {
|
|
19
|
+
id: 1,
|
|
20
|
+
layout: enums_1.OrientationEnum.horizontal,
|
|
21
|
+
cardStyle: {
|
|
22
|
+
card_title_color: "#000000",
|
|
23
|
+
card_description_color: "#666666",
|
|
24
|
+
card_shadow_toggle: 1,
|
|
25
|
+
card_shadow_color: "rgba(0,0,0,0.2)",
|
|
26
|
+
card_background_color: "#ffffff",
|
|
27
|
+
card_button_background_color: "#f5f5f5",
|
|
28
|
+
card_button_text_color: "#333333",
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
describe("ContactProfile Component", function () {
|
|
32
|
+
it("renders ContactProfileTheme1 when layout is horizontal", function () {
|
|
33
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ContactProfile_1.ContactProfile, __assign({}, mockProps)));
|
|
34
|
+
expect(react_1.screen.getByTestId("contact-profile-theme1")).toBeInTheDocument();
|
|
35
|
+
});
|
|
36
|
+
it("renders ContactProfileTheme2 when layout is vertical", function () {
|
|
37
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ContactProfile_1.ContactProfile, __assign({}, mockProps, { layout: enums_1.OrientationEnum.vertical })));
|
|
38
|
+
expect(react_1.screen.getByTestId("contact-profile-theme2")).toBeInTheDocument();
|
|
39
|
+
});
|
|
40
|
+
it("applies correct styles based on id", function () {
|
|
41
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ContactProfile_1.ContactProfile, __assign({}, mockProps)));
|
|
42
|
+
var styles = document.styleSheets[document.styleSheets.length - 1].cssRules;
|
|
43
|
+
expect(Array.from(styles).some(function (rule) {
|
|
44
|
+
return rule.cssText.includes(".card_ContactProfile_title_color_1");
|
|
45
|
+
})).toBeTruthy();
|
|
46
|
+
expect(Array.from(styles).some(function (rule) {
|
|
47
|
+
return rule.cssText.includes(".card_bg_ContactProfile_1");
|
|
48
|
+
})).toBeTruthy();
|
|
49
|
+
});
|
|
50
|
+
it("applies default shadow when card_shadow_toggle is not 1", function () {
|
|
51
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ContactProfile_1.ContactProfile, __assign({}, mockProps, { cardStyle: __assign(__assign({}, mockProps.cardStyle), { card_shadow_toggle: 0 }) })));
|
|
52
|
+
var styles = document.styleSheets[document.styleSheets.length - 1].cssRules;
|
|
53
|
+
expect(Array.from(styles).some(function (rule) {
|
|
54
|
+
return rule.cssText.includes("box-shadow: 0px 4px 12px 0px rgba(52, 52, 52, 0.15)");
|
|
55
|
+
})).toBeTruthy();
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -11,6 +11,6 @@ var link_1 = __importDefault(require("next/link"));
|
|
|
11
11
|
var card_module_css_1 = __importDefault(require("../card.module.css"));
|
|
12
12
|
var enums_1 = require("../../../utils/enums");
|
|
13
13
|
var ContactProfileTheme1 = function (props) {
|
|
14
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "lu-pd-250 card_bg_ContactProfile_".concat(props.id, " lu-border-rounded-xl ").concat(props.className, " card_shadow_ContactProfile_").concat(props.id), children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex gap-x-5", children: [(0, jsx_runtime_1.jsx)("div", { className: "max-w-[240px] overflow-hidden lu-aspect-square ".concat(card_module_css_1.default.horizontal_card_image), children: (0, jsx_runtime_1.jsx)(LuImage_1.LuImage, { image: props.image, aspectRatio: "", width: 160, height: 160, className: "lu-border-rounded-full lu-height-100 object-cover"
|
|
14
|
+
return ((0, jsx_runtime_1.jsxs)("div", { "data-testid": "contact-profile-theme1", className: "lu-pd-250 card_bg_ContactProfile_".concat(props.id, " lu-border-rounded-xl ").concat(props.className, " card_shadow_ContactProfile_").concat(props.id), children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex gap-x-5", children: [(0, jsx_runtime_1.jsx)("div", { className: "max-w-[240px] overflow-hidden lu-aspect-square ".concat(card_module_css_1.default.horizontal_card_image), children: (0, jsx_runtime_1.jsx)(LuImage_1.LuImage, { image: props.image, aspectRatio: "", width: 160, height: 160, className: "lu-border-rounded-full lu-height-100 object-cover" }) }), (0, jsx_runtime_1.jsx)("div", { className: "flex flex-1 flex-col", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col justify-center flex-1 lu-height-100", children: [(0, jsx_runtime_1.jsx)("div", { className: "card_ContactProfile_title_color_".concat(props.id, " lu-font-size-2x-large lu-font-weight-semibold ").concat(card_module_css_1.default.horizontal_card_heading), children: props.heading }), (0, jsx_runtime_1.jsx)("p", { className: "lu-base-font-size lu-font-weight-extra-light card_ContactProfile_designation_color_".concat(props.id, " ").concat(card_module_css_1.default.horizontal_body_text), children: props.body })] }) })] }), (0, jsx_runtime_1.jsx)(link_1.default, { href: props.href || "", passHref: true, className: "lu-width-100 lu-text-decoration-none", children: (0, jsx_runtime_1.jsx)(Button_1.Button, { contentType: enums_1.ContentType.text_with_icon, label: props.btnLabel, variant: "card_ContactProfile_btn_".concat(props.id), iconRight: "angle-right", rightIconSize: "lu-icon-small", size: "lu-btn-lg", className: "lu-border-rounded-sm justify-between lu-width-100 lu-mt-200 ".concat(card_module_css_1.default.card_button, " card_ContactProfile_btn_").concat(props.id) }) })] }));
|
|
15
15
|
};
|
|
16
16
|
exports.ContactProfileTheme1 = ContactProfileTheme1;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@testing-library/jest-dom";
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
54
|
+
var react_1 = require("@testing-library/react");
|
|
55
|
+
require("@testing-library/jest-dom");
|
|
56
|
+
var ContactProfileTheme1_1 = require("./ContactProfileTheme1");
|
|
57
|
+
var user_event_1 = __importDefault(require("@testing-library/user-event"));
|
|
58
|
+
describe("ContactProfileTheme1 Component", function () {
|
|
59
|
+
var mockProps = {
|
|
60
|
+
id: 1,
|
|
61
|
+
heading: "John Doe",
|
|
62
|
+
body: "Software Engineer",
|
|
63
|
+
image: "https://via.placeholder.com/150",
|
|
64
|
+
btnLabel: "View Profile",
|
|
65
|
+
href: "/profile",
|
|
66
|
+
className: "custom-class",
|
|
67
|
+
};
|
|
68
|
+
jest.mock("next/image", function () { return ({
|
|
69
|
+
__esModule: true,
|
|
70
|
+
default: function (props) {
|
|
71
|
+
var _a;
|
|
72
|
+
return ((0, jsx_runtime_1.jsx)("img", __assign({}, props, { alt: props.btnLabel || "", id: (_a = props.id) === null || _a === void 0 ? void 0 : _a.toString() })));
|
|
73
|
+
},
|
|
74
|
+
}); });
|
|
75
|
+
it("Render the contact profile theme1 with correct body and heading text", function () {
|
|
76
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ContactProfileTheme1_1.ContactProfileTheme1, __assign({}, mockProps)));
|
|
77
|
+
var headingElement = react_1.screen.getByText(mockProps.heading);
|
|
78
|
+
var bodyElement = react_1.screen.getByText(mockProps.body);
|
|
79
|
+
expect(headingElement).toBeInTheDocument();
|
|
80
|
+
expect(bodyElement).toBeInTheDocument();
|
|
81
|
+
});
|
|
82
|
+
it("renders the profile image", function () {
|
|
83
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ContactProfileTheme1_1.ContactProfileTheme1, __assign({}, mockProps)));
|
|
84
|
+
var profileImage = react_1.screen.getByAltText("Image");
|
|
85
|
+
expect(profileImage).toBeInTheDocument();
|
|
86
|
+
expect(profileImage).toHaveAttribute("alt", "Image"); // Matches the default alt in LuImage
|
|
87
|
+
});
|
|
88
|
+
it("renders the button with correct label and icon", function () {
|
|
89
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ContactProfileTheme1_1.ContactProfileTheme1, __assign({}, mockProps)));
|
|
90
|
+
var buttonElement = react_1.screen.getByRole("button", {
|
|
91
|
+
name: mockProps.btnLabel,
|
|
92
|
+
});
|
|
93
|
+
expect(buttonElement).toBeInTheDocument();
|
|
94
|
+
expect(buttonElement).toHaveTextContent(mockProps.btnLabel);
|
|
95
|
+
});
|
|
96
|
+
it("renders the link with the correct href", function () {
|
|
97
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ContactProfileTheme1_1.ContactProfileTheme1, __assign({}, mockProps)));
|
|
98
|
+
var linkElement = react_1.screen.getByRole("link");
|
|
99
|
+
expect(linkElement).toHaveAttribute("href", mockProps.href);
|
|
100
|
+
});
|
|
101
|
+
it("triggers navigation when the button is clicked", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
102
|
+
var user, linkElement;
|
|
103
|
+
return __generator(this, function (_a) {
|
|
104
|
+
switch (_a.label) {
|
|
105
|
+
case 0:
|
|
106
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ContactProfileTheme1_1.ContactProfileTheme1, __assign({}, mockProps)));
|
|
107
|
+
user = user_event_1.default.setup();
|
|
108
|
+
linkElement = react_1.screen.getByRole("link");
|
|
109
|
+
return [4 /*yield*/, user.click(linkElement)];
|
|
110
|
+
case 1:
|
|
111
|
+
_a.sent();
|
|
112
|
+
expect(linkElement).toHaveAttribute("href", mockProps.href);
|
|
113
|
+
return [2 /*return*/];
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}); });
|
|
117
|
+
it("renders without crashing when href is undefined", function () {
|
|
118
|
+
var propsWithoutHref = __assign(__assign({}, mockProps), { href: undefined });
|
|
119
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ContactProfileTheme1_1.ContactProfileTheme1, __assign({}, propsWithoutHref)));
|
|
120
|
+
expect(react_1.screen.getByRole("button")).toBeInTheDocument();
|
|
121
|
+
});
|
|
122
|
+
});
|
|
@@ -11,6 +11,6 @@ var link_1 = __importDefault(require("next/link"));
|
|
|
11
11
|
var card_module_css_1 = __importDefault(require("../card.module.css"));
|
|
12
12
|
var enums_1 = require("../../../utils/enums");
|
|
13
13
|
var ContactProfileTheme2 = function (props) {
|
|
14
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "lu-pd-400 card_bg_ContactProfile_".concat(props.id, " lu-border-rounded-xl ").concat(props.className, " card_shadow_ContactProfile_").concat(props.id, " flex flex-col items-center"), children: [(0, jsx_runtime_1.jsx)("div", { className: "max-w-[160px] overflow-hidden lu-aspect-square", children: (0, jsx_runtime_1.jsx)(LuImage_1.LuImage, { image: props.image, width: 160, height: 160, className: "lu-height-100 object-cover lu-border-rounded-full", orientation: props.mediaPosition }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-center flex-grow lu-m-250 text-center h-[100px]", children: [(0, jsx_runtime_1.jsx)("div", { className: "card_ContactProfile_title_color_".concat(props.id, " lu-font-size-2x-large lu-font-weight-semibold ").concat(card_module_css_1.default.vertical_card_heading), children: props.heading }), (0, jsx_runtime_1.jsx)("p", { className: "lu-base-font-size lu-font-weight-extra-light card_ContactProfile_designation_color_".concat(props.id, " ").concat(card_module_css_1.default.vertical_body_text), children: props.body })] }), (0, jsx_runtime_1.jsx)(link_1.default, { href: props.href || "", className: "lu-width-100 lu-text-decoration-none", children: (0, jsx_runtime_1.jsx)(Button_1.Button, { contentType: enums_1.ContentType.text_with_icon, label: props.btnLabel, variant: "card_ContactProfile_btn_".concat(props.id), iconRight: "angle-right", rightIconSize: "lu-icon-small", size: "lu-btn-lg", className: "lu-border-rounded-sm justify-between lu-width-100 card_ContactProfile_btn_".concat(props.id) }) })] }));
|
|
14
|
+
return ((0, jsx_runtime_1.jsxs)("div", { "data-testid": "contact-profile-theme2", className: "lu-pd-400 card_bg_ContactProfile_".concat(props.id, " lu-border-rounded-xl ").concat(props.className, " card_shadow_ContactProfile_").concat(props.id, " flex flex-col items-center"), children: [(0, jsx_runtime_1.jsx)("div", { className: "max-w-[160px] overflow-hidden lu-aspect-square", children: (0, jsx_runtime_1.jsx)(LuImage_1.LuImage, { image: props.image, width: 160, height: 160, className: "lu-height-100 object-cover lu-border-rounded-full", orientation: props.mediaPosition }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-center flex-grow lu-m-250 text-center h-[100px]", children: [(0, jsx_runtime_1.jsx)("div", { className: "card_ContactProfile_title_color_".concat(props.id, " lu-font-size-2x-large lu-font-weight-semibold ").concat(card_module_css_1.default.vertical_card_heading), children: props.heading }), (0, jsx_runtime_1.jsx)("p", { className: "lu-base-font-size lu-font-weight-extra-light card_ContactProfile_designation_color_".concat(props.id, " ").concat(card_module_css_1.default.vertical_body_text), children: props.body })] }), (0, jsx_runtime_1.jsx)(link_1.default, { href: props.href || "", passHref: true, className: "lu-width-100 lu-text-decoration-none", children: (0, jsx_runtime_1.jsx)(Button_1.Button, { contentType: enums_1.ContentType.text_with_icon, label: props.btnLabel, variant: "card_ContactProfile_btn_".concat(props.id), iconRight: "angle-right", rightIconSize: "lu-icon-small", size: "lu-btn-lg", className: "lu-border-rounded-sm justify-between lu-width-100 card_ContactProfile_btn_".concat(props.id) }) })] }));
|
|
15
15
|
};
|
|
16
16
|
exports.ContactProfileTheme2 = ContactProfileTheme2;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@testing-library/jest-dom";
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
54
|
+
var react_1 = require("@testing-library/react");
|
|
55
|
+
require("@testing-library/jest-dom");
|
|
56
|
+
var ContactProfileTheme2_1 = require("./ContactProfileTheme2");
|
|
57
|
+
var user_event_1 = __importDefault(require("@testing-library/user-event"));
|
|
58
|
+
describe("ContactProfileTheme1 Component", function () {
|
|
59
|
+
var mockProps = {
|
|
60
|
+
id: 1,
|
|
61
|
+
heading: "John Doe",
|
|
62
|
+
body: "Software Engineer",
|
|
63
|
+
image: "https://via.placeholder.com/150",
|
|
64
|
+
btnLabel: "View Profile",
|
|
65
|
+
href: "/profile",
|
|
66
|
+
className: "custom-class",
|
|
67
|
+
};
|
|
68
|
+
jest.mock("next/image", function () { return ({
|
|
69
|
+
__esModule: true,
|
|
70
|
+
default: function (props) {
|
|
71
|
+
var _a;
|
|
72
|
+
return ((0, jsx_runtime_1.jsx)("img", __assign({}, props, { alt: props.btnLabel || "", id: (_a = props.id) === null || _a === void 0 ? void 0 : _a.toString() })));
|
|
73
|
+
}, // Renders a normal <img> tag
|
|
74
|
+
}); });
|
|
75
|
+
it("Render the contact profile theme1 with correct body and heading text", function () {
|
|
76
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ContactProfileTheme2_1.ContactProfileTheme2, __assign({}, mockProps)));
|
|
77
|
+
var headingElement = react_1.screen.getByText(mockProps.heading);
|
|
78
|
+
var bodyElement = react_1.screen.getByText(mockProps.body);
|
|
79
|
+
expect(headingElement).toBeInTheDocument();
|
|
80
|
+
expect(bodyElement).toBeInTheDocument();
|
|
81
|
+
});
|
|
82
|
+
it("renders the profile image", function () {
|
|
83
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ContactProfileTheme2_1.ContactProfileTheme2, __assign({}, mockProps)));
|
|
84
|
+
var profileImage = react_1.screen.getByAltText("Image");
|
|
85
|
+
expect(profileImage).toBeInTheDocument();
|
|
86
|
+
expect(profileImage).toHaveAttribute("alt", "Image"); // Matches the default alt in LuImage
|
|
87
|
+
});
|
|
88
|
+
it("renders the button with correct label and icon", function () {
|
|
89
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ContactProfileTheme2_1.ContactProfileTheme2, __assign({}, mockProps)));
|
|
90
|
+
var buttonElement = react_1.screen.getByRole("button", {
|
|
91
|
+
name: mockProps.btnLabel,
|
|
92
|
+
});
|
|
93
|
+
expect(buttonElement).toBeInTheDocument();
|
|
94
|
+
expect(buttonElement).toHaveTextContent(mockProps.btnLabel);
|
|
95
|
+
});
|
|
96
|
+
it("renders the link with the correct href", function () {
|
|
97
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ContactProfileTheme2_1.ContactProfileTheme2, __assign({}, mockProps)));
|
|
98
|
+
var linkElement = react_1.screen.getByRole("link");
|
|
99
|
+
expect(linkElement).toHaveAttribute("href", mockProps.href);
|
|
100
|
+
});
|
|
101
|
+
it("triggers navigation when the button is clicked", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
102
|
+
var user, linkElement;
|
|
103
|
+
return __generator(this, function (_a) {
|
|
104
|
+
switch (_a.label) {
|
|
105
|
+
case 0:
|
|
106
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ContactProfileTheme2_1.ContactProfileTheme2, __assign({}, mockProps)));
|
|
107
|
+
user = user_event_1.default.setup();
|
|
108
|
+
linkElement = react_1.screen.getByRole("link");
|
|
109
|
+
return [4 /*yield*/, user.click(linkElement)];
|
|
110
|
+
case 1:
|
|
111
|
+
_a.sent();
|
|
112
|
+
expect(linkElement).toHaveAttribute("href", mockProps.href);
|
|
113
|
+
return [2 /*return*/];
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}); });
|
|
117
|
+
it("renders without crashing when href is undefined", function () {
|
|
118
|
+
var propsWithoutHref = __assign(__assign({}, mockProps), { href: undefined });
|
|
119
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ContactProfileTheme2_1.ContactProfileTheme2, __assign({}, propsWithoutHref)));
|
|
120
|
+
expect(react_1.screen.getByRole("button")).toBeInTheDocument();
|
|
121
|
+
});
|
|
122
|
+
});
|
|
@@ -20,7 +20,7 @@ var PostByCategoryTheme2_1 = require("./PostByCategoryTheme2");
|
|
|
20
20
|
var enums_1 = require("../../../utils/enums");
|
|
21
21
|
var PostByCategory = function (props) {
|
|
22
22
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
23
|
-
return ((0, jsx_runtime_1.jsxs)("div", { children: [props.layout === enums_1.OrientationEnum.horizontal ? ((0, jsx_runtime_1.jsx)(PostByCategoryTheme1_1.PostByCategoryTheme1, __assign({}, props))) : ((0, jsx_runtime_1.jsx)(
|
|
23
|
+
return ((0, jsx_runtime_1.jsxs)("div", { children: [props.layout === enums_1.OrientationEnum.horizontal ? ((0, jsx_runtime_1.jsx)(PostByCategoryTheme1_1.PostByCategoryTheme1, __assign({}, props))) : ((0, jsx_runtime_1.jsx)(PostByCategoryTheme2_1.PostByCategoryTheme2, __assign({}, props))), (0, jsx_runtime_1.jsx)("style", { jsx: true, global: true, children: "\n .card_PostByCategory_title_color_".concat(props.id, " {\n color: ").concat((0, scripts_1.getColor)((_a = props.cardStyle) === null || _a === void 0 ? void 0 : _a.card_title_color, colors_1.colors === null || colors_1.colors === void 0 ? void 0 : colors_1.colors.default), ";\n }\n .card_PostByCategory_description_color_").concat(props.id, " {\n color: ").concat((0, scripts_1.getColor)((_b = props.cardStyle) === null || _b === void 0 ? void 0 : _b.card_description_color, colors_1.colors.caption_color), ";\n }\n .card_shadow_PostByCategory_").concat(props.id, " {\n box-shadow: ").concat(((_c = props.cardStyle) === null || _c === void 0 ? void 0 : _c.card_shadow_toggle) === 1
|
|
24
24
|
? "0px 4px 12px 0px ".concat((0, scripts_1.getColor)((_d = props.cardStyle) === null || _d === void 0 ? void 0 : _d.card_shadow_color, "rgba(52, 52, 52, 0.15)"))
|
|
25
25
|
: "0px 4px 12px 0px rgba(52, 52, 52, 0.15)", ";\n }\n .card_bg_PostByCategory_").concat(props.id, " {\n background-color: ").concat((0, scripts_1.getColor)((_e = props.cardStyle) === null || _e === void 0 ? void 0 : _e.card_background_color, colors_1.colors.white), " !important;\n }\n .card_PostByCategory_btn_").concat(props.id, " {\n background-color: ").concat((0, scripts_1.getColor)((_f = props.cardStyle) === null || _f === void 0 ? void 0 : _f.card_button_background_color, colors_1.colors.gray), " !important;\n color: ").concat((0, scripts_1.getColor)((_g = props.cardStyle) === null || _g === void 0 ? void 0 : _g.card_button_text_color, colors_1.colors.neutral), " !important;\n fill: ").concat((0, scripts_1.getColor)((_h = props.cardStyle) === null || _h === void 0 ? void 0 : _h.card_button_text_color, colors_1.colors.neutral), " !important;\n }\n .card_PostByCategory_btn_").concat(props.id, ":hover {\n background-color: ").concat((0, scripts_1.getColor)((_j = props.cardStyle) === null || _j === void 0 ? void 0 : _j.card_button_background_color, colors_1.colors.gray), " !important;\n color: ").concat((0, scripts_1.getColor)((_k = props.cardStyle) === null || _k === void 0 ? void 0 : _k.card_button_text_color, colors_1.colors.neutral), " !important;\n fill: ").concat((0, scripts_1.getColor)((_l = props.cardStyle) === null || _l === void 0 ? void 0 : _l.card_button_text_color, colors_1.colors.neutral), " !important;\n }\n .card_PostByCategory_theme2_image_").concat(props === null || props === void 0 ? void 0 : props.id, " {\n border-color: ").concat((0, scripts_1.getColor)((_m = props.cardStyle) === null || _m === void 0 ? void 0 : _m.card_image_border_color, colors_1.colors === null || colors_1.colors === void 0 ? void 0 : colors_1.colors.default), " !important;\n border-radius: ").concat((0, scripts_1.ensureValue)((_o = props.cardStyle) === null || _o === void 0 ? void 0 : _o.card_image_border_radius, "0"), "%;\n border: ").concat((0, scripts_1.ensureValue)((_p = props.cardStyle) === null || _p === void 0 ? void 0 : _p.card_image_border, "0"), "px\n solid;\n }\n ") })] }));
|
|
26
26
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
15
|
+
var react_1 = require("@testing-library/react");
|
|
16
|
+
var PostByCategory_1 = require("./PostByCategory");
|
|
17
|
+
var enums_1 = require("../../../utils/enums");
|
|
18
|
+
var mockProps = {
|
|
19
|
+
id: 1,
|
|
20
|
+
layout: enums_1.OrientationEnum.horizontal,
|
|
21
|
+
cardStyle: {
|
|
22
|
+
card_title_color: "#000000",
|
|
23
|
+
card_description_color: "#666666",
|
|
24
|
+
card_shadow_toggle: 1,
|
|
25
|
+
card_shadow_color: "rgba(0,0,0,0.2)",
|
|
26
|
+
card_background_color: "#ffffff",
|
|
27
|
+
card_button_background_color: "#f5f5f5",
|
|
28
|
+
card_button_text_color: "#333333",
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
describe("PostByCategory Component", function () {
|
|
32
|
+
it("renders PostByCategoryTheme1 when layout is horizontal", function () {
|
|
33
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(PostByCategory_1.PostByCategory, __assign({}, mockProps)));
|
|
34
|
+
expect(react_1.screen.getByTestId("postByCategory-theme1")).toBeInTheDocument();
|
|
35
|
+
});
|
|
36
|
+
it("renders PostByCategoryTheme2 when layout is vertical", function () {
|
|
37
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(PostByCategory_1.PostByCategory, __assign({}, mockProps, { layout: enums_1.OrientationEnum.vertical })));
|
|
38
|
+
expect(react_1.screen.getByTestId("postByCategory-theme2")).toBeInTheDocument();
|
|
39
|
+
});
|
|
40
|
+
it("applies correct styles based on id", function () {
|
|
41
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(PostByCategory_1.PostByCategory, __assign({}, mockProps)));
|
|
42
|
+
var styles = document.styleSheets[document.styleSheets.length - 1].cssRules;
|
|
43
|
+
expect(Array.from(styles).some(function (rule) {
|
|
44
|
+
return rule.cssText.includes(".card_PostByCategory_title_color_1");
|
|
45
|
+
})).toBeTruthy();
|
|
46
|
+
expect(Array.from(styles).some(function (rule) {
|
|
47
|
+
return rule.cssText.includes(".card_bg_PostByCategory_1");
|
|
48
|
+
})).toBeTruthy();
|
|
49
|
+
});
|
|
50
|
+
it("applies default shadow when card_shadow_toggle is not 1", function () {
|
|
51
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(PostByCategory_1.PostByCategory, __assign({}, mockProps, { cardStyle: __assign(__assign({}, mockProps.cardStyle), { card_shadow_toggle: 0 }) })));
|
|
52
|
+
var styles = document.styleSheets[document.styleSheets.length - 1].cssRules;
|
|
53
|
+
expect(Array.from(styles).some(function (rule) {
|
|
54
|
+
return rule.cssText.includes("box-shadow: 0px 4px 12px 0px rgba(52, 52, 52, 0.15)");
|
|
55
|
+
})).toBeTruthy();
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -11,6 +11,6 @@ var Button_1 = require("../../../components/Button/Button");
|
|
|
11
11
|
var card_module_css_1 = __importDefault(require("../card.module.css"));
|
|
12
12
|
var enums_1 = require("../../../utils/enums");
|
|
13
13
|
var PostByCategoryTheme1 = function (props) {
|
|
14
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "lu-pd-250 card_bg_PostByCategory_".concat(props.id, " lu-border-rounded-xl ").concat(props.className, " card_shadow_PostByCategory_").concat(props.id, " flex gap-x-[20px] lu-width-100"), children: [(0, jsx_runtime_1.jsx)("div", { className: "lu-width-100 max-w-[240px] overflow-hidden lu-aspect-square horizontal_card_image", children: (0, jsx_runtime_1.jsx)(LuImage_1.LuImage, { image: props.image, width: 240, height: 240, className: "lu-border-rounded-lg lu-width-100 lu-height-100 object-cover", orientation: props.mediaPosition }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-1 flex-col", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col justify-center flex-1 h-full", children: [(0, jsx_runtime_1.jsx)("div", { className: "card_PostByCategory_title_color_".concat(props.id, " lu-font-size-2x-large lu-font-weight-semibold ").concat(card_module_css_1.default.horizontal_card_heading), children: props.heading }), (0, jsx_runtime_1.jsx)("p", { className: "card_PostByCategory_description_color_".concat(props.id, " lu-base-font-size lu-font-weight-extra-light ").concat(card_module_css_1.default.horizontal_body_text), children: props.body })] }), (0, jsx_runtime_1.jsx)(link_1.default, { href: props.href || "", className: "lu-width-100 lu-text-decoration-none", children: (0, jsx_runtime_1.jsx)(Button_1.Button, { contentType: enums_1.ContentType.text_with_icon, label: props.btnLabel, variant: "card_PostByCategory_btn_".concat(props.id), iconRight: "angle-right", rightIconSize: "lu-icon-small", size: "lu-btn-lg", className: "lu-border-rounded-sm justify-between lu-width-100 ".concat(card_module_css_1.default.card_button, " card_PostByCategory_btn_").concat(props.id) }) })] })] }));
|
|
14
|
+
return ((0, jsx_runtime_1.jsxs)("div", { "data-testid": "postByCategory-theme1", className: "lu-pd-250 card_bg_PostByCategory_".concat(props.id, " lu-border-rounded-xl ").concat(props.className, " card_shadow_PostByCategory_").concat(props.id, " flex gap-x-[20px] lu-width-100"), children: [(0, jsx_runtime_1.jsx)("div", { className: "lu-width-100 max-w-[240px] overflow-hidden lu-aspect-square horizontal_card_image", children: (0, jsx_runtime_1.jsx)(LuImage_1.LuImage, { image: props.image, width: 240, height: 240, className: "lu-border-rounded-lg lu-width-100 lu-height-100 object-cover", orientation: props.mediaPosition }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-1 flex-col", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col justify-center flex-1 h-full", children: [(0, jsx_runtime_1.jsx)("div", { className: "card_PostByCategory_title_color_".concat(props.id, " lu-font-size-2x-large lu-font-weight-semibold ").concat(card_module_css_1.default.horizontal_card_heading), children: props.heading }), (0, jsx_runtime_1.jsx)("p", { className: "card_PostByCategory_description_color_".concat(props.id, " lu-base-font-size lu-font-weight-extra-light ").concat(card_module_css_1.default.horizontal_body_text), children: props.body })] }), (0, jsx_runtime_1.jsx)(link_1.default, { href: props.href || "", passHref: true, className: "lu-width-100 lu-text-decoration-none", children: (0, jsx_runtime_1.jsx)(Button_1.Button, { contentType: enums_1.ContentType.text_with_icon, label: props.btnLabel, variant: "card_PostByCategory_btn_".concat(props.id), iconRight: "angle-right", rightIconSize: "lu-icon-small", size: "lu-btn-lg", className: "lu-border-rounded-sm justify-between lu-width-100 ".concat(card_module_css_1.default.card_button, " card_PostByCategory_btn_").concat(props.id) }) })] })] }));
|
|
15
15
|
};
|
|
16
16
|
exports.PostByCategoryTheme1 = PostByCategoryTheme1;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@testing-library/jest-dom";
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
54
|
+
var react_1 = require("@testing-library/react");
|
|
55
|
+
require("@testing-library/jest-dom");
|
|
56
|
+
var PostByCategoryTheme1_1 = require("./PostByCategoryTheme1");
|
|
57
|
+
var user_event_1 = __importDefault(require("@testing-library/user-event"));
|
|
58
|
+
describe("PostByCategoryTheme1 Component", function () {
|
|
59
|
+
var mockProps = {
|
|
60
|
+
id: 1,
|
|
61
|
+
heading: "John Doe",
|
|
62
|
+
body: "Software Engineer",
|
|
63
|
+
image: "https://via.placeholder.com/150",
|
|
64
|
+
btnLabel: "View Profile",
|
|
65
|
+
href: "/profile",
|
|
66
|
+
className: "custom-class",
|
|
67
|
+
};
|
|
68
|
+
jest.mock("next/image", function () { return ({
|
|
69
|
+
__esModule: true,
|
|
70
|
+
default: function (props) {
|
|
71
|
+
var _a;
|
|
72
|
+
return ((0, jsx_runtime_1.jsx)("img", __assign({}, props, { id: (_a = props.id) === null || _a === void 0 ? void 0 : _a.toString(), alt: props.btnLabel || "" })));
|
|
73
|
+
}, // Renders a normal <img> tag
|
|
74
|
+
}); });
|
|
75
|
+
it("Render the post by category theme1 with correct body and heading text", function () {
|
|
76
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(PostByCategoryTheme1_1.PostByCategoryTheme1, __assign({}, mockProps)));
|
|
77
|
+
var headingElement = react_1.screen.getByText(mockProps.heading);
|
|
78
|
+
var bodyElement = react_1.screen.getByText(mockProps.body);
|
|
79
|
+
expect(headingElement).toBeInTheDocument();
|
|
80
|
+
expect(bodyElement).toBeInTheDocument();
|
|
81
|
+
});
|
|
82
|
+
it("renders the profile image", function () {
|
|
83
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(PostByCategoryTheme1_1.PostByCategoryTheme1, __assign({}, mockProps)));
|
|
84
|
+
var profileImage = react_1.screen.getByAltText("Image");
|
|
85
|
+
expect(profileImage).toBeInTheDocument();
|
|
86
|
+
expect(profileImage).toHaveAttribute("alt", "Image"); // Matches the default alt in LuImage
|
|
87
|
+
});
|
|
88
|
+
it("renders the button with correct label and icon", function () {
|
|
89
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(PostByCategoryTheme1_1.PostByCategoryTheme1, __assign({}, mockProps)));
|
|
90
|
+
var buttonElement = react_1.screen.getByRole("button", {
|
|
91
|
+
name: mockProps.btnLabel,
|
|
92
|
+
});
|
|
93
|
+
expect(buttonElement).toBeInTheDocument();
|
|
94
|
+
expect(buttonElement).toHaveTextContent(mockProps.btnLabel);
|
|
95
|
+
});
|
|
96
|
+
it("renders the link with the correct href", function () {
|
|
97
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(PostByCategoryTheme1_1.PostByCategoryTheme1, __assign({}, mockProps)));
|
|
98
|
+
var linkElement = react_1.screen.getByRole("link");
|
|
99
|
+
expect(linkElement).toHaveAttribute("href", mockProps.href);
|
|
100
|
+
});
|
|
101
|
+
it("triggers navigation when the button is clicked", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
102
|
+
var user, linkElement;
|
|
103
|
+
return __generator(this, function (_a) {
|
|
104
|
+
switch (_a.label) {
|
|
105
|
+
case 0:
|
|
106
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(PostByCategoryTheme1_1.PostByCategoryTheme1, __assign({}, mockProps)));
|
|
107
|
+
user = user_event_1.default.setup();
|
|
108
|
+
linkElement = react_1.screen.getByRole("link");
|
|
109
|
+
return [4 /*yield*/, user.click(linkElement)];
|
|
110
|
+
case 1:
|
|
111
|
+
_a.sent();
|
|
112
|
+
expect(linkElement).toHaveAttribute("href", mockProps.href);
|
|
113
|
+
return [2 /*return*/];
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}); });
|
|
117
|
+
it("renders without crashing when href is undefined", function () {
|
|
118
|
+
var propsWithoutHref = __assign(__assign({}, mockProps), { href: undefined });
|
|
119
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(PostByCategoryTheme1_1.PostByCategoryTheme1, __assign({}, propsWithoutHref)));
|
|
120
|
+
expect(react_1.screen.getByRole("button")).toBeInTheDocument();
|
|
121
|
+
});
|
|
122
|
+
});
|
|
@@ -11,6 +11,6 @@ var Button_1 = require("../../../components/Button/Button");
|
|
|
11
11
|
var card_module_css_1 = __importDefault(require("../card.module.css"));
|
|
12
12
|
var enums_1 = require("../../../utils/enums");
|
|
13
13
|
var PostByCategoryTheme2 = function (props) {
|
|
14
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "lu-pd-400 card_bg_PostByCategory_".concat(props.id, " lu-border-rounded-xl ").concat(props.className, " card_shadow_PostByCategory_").concat(props.id, " flex flex-col items-center lu-width-100"), children: [(0, jsx_runtime_1.jsx)("div", { className: "lu-width-100 max-w-[240px] overflow-hidden lu-aspect-square", children: (0, jsx_runtime_1.jsx)(LuImage_1.LuImage, { image: props.image, width: 240, height: 240, className: "lu-width-100 lu-height-100 object-cover card_PostByCategory_theme2_image_".concat(props === null || props === void 0 ? void 0 : props.id), orientation: props.mediaPosition }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-center flex-grow lu-m-250 text-center h-[100px]", children: [(0, jsx_runtime_1.jsx)("div", { className: "card_PostByCategory_title_color_".concat(props.id, " lu-font-size-2x-large lu-font-weight-semibold ").concat(card_module_css_1.default.vertical_card_heading), children: props.heading }), (0, jsx_runtime_1.jsx)("p", { className: "card_PostByCategory_description_color_".concat(props.id, " lu-base-font-size lu-font-weight-extra-light ").concat(card_module_css_1.default.vertical_body_text), children: props.body })] }), (0, jsx_runtime_1.jsx)(link_1.default, { href: props.href || "", className: "lu-width-100 lu-text-decoration-none", children: (0, jsx_runtime_1.jsx)(Button_1.Button, { contentType: enums_1.ContentType.text_with_icon, label: props.btnLabel, variant: "card_PostByCategory_btn_".concat(props.id), iconRight: "angle-right", rightIconSize: "lu-icon-small", size: "lu-btn-lg", className: "lu-border-rounded-sm justify-between lu-width-100 card_PostByCategory_btn_".concat(props.id) }) })] }));
|
|
14
|
+
return ((0, jsx_runtime_1.jsxs)("div", { "data-testid": "postByCategory-theme2", className: "lu-pd-400 card_bg_PostByCategory_".concat(props.id, " lu-border-rounded-xl ").concat(props.className, " card_shadow_PostByCategory_").concat(props.id, " flex flex-col items-center lu-width-100"), children: [(0, jsx_runtime_1.jsx)("div", { className: "lu-width-100 max-w-[240px] overflow-hidden lu-aspect-square", children: (0, jsx_runtime_1.jsx)(LuImage_1.LuImage, { image: props.image, width: 240, height: 240, className: "lu-width-100 lu-height-100 object-cover card_PostByCategory_theme2_image_".concat(props === null || props === void 0 ? void 0 : props.id), orientation: props.mediaPosition }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-center flex-grow lu-m-250 text-center h-[100px]", children: [(0, jsx_runtime_1.jsx)("div", { className: "card_PostByCategory_title_color_".concat(props.id, " lu-font-size-2x-large lu-font-weight-semibold ").concat(card_module_css_1.default.vertical_card_heading), children: props.heading }), (0, jsx_runtime_1.jsx)("p", { className: "card_PostByCategory_description_color_".concat(props.id, " lu-base-font-size lu-font-weight-extra-light ").concat(card_module_css_1.default.vertical_body_text), children: props.body })] }), (0, jsx_runtime_1.jsx)(link_1.default, { href: props.href || "", passHref: true, className: "lu-width-100 lu-text-decoration-none", children: (0, jsx_runtime_1.jsx)(Button_1.Button, { contentType: enums_1.ContentType.text_with_icon, label: props.btnLabel, variant: "card_PostByCategory_btn_".concat(props.id), iconRight: "angle-right", rightIconSize: "lu-icon-small", size: "lu-btn-lg", className: "lu-border-rounded-sm justify-between lu-width-100 card_PostByCategory_btn_".concat(props.id) }) })] }));
|
|
15
15
|
};
|
|
16
16
|
exports.PostByCategoryTheme2 = PostByCategoryTheme2;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@testing-library/jest-dom";
|