aloha-vue 2.74.0 → 2.75.0
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/CHANGELOG.md +8 -0
- package/LICENSE +22 -21
- package/dist/aloha-vue.css +13594 -13594
- package/dist/aloha-vue.css.map +1 -1
- package/dist/aloha-vue.es.js +59266 -64918
- package/dist/aloha-vue.umd.js +338 -211
- package/package.json +27 -34
- package/scss/components/ATable.scss +2 -2
- package/scss/utils/button.scss +362 -362
- package/scss/utils/funktions.scss +162 -162
- package/src/AAccordion/AAccordionItem/AAccordionItem.js +235 -230
- package/src/ACarousel/ACarousel.js +7 -2
- package/src/ADropdown/ADropdown.js +4 -1
- package/src/AFilters/AFilterCenter/AFilterCenter.js +5 -1
- package/src/AFilters/AFilterCenter/AFilterCenterItem/AFilterCenterItem.js +7 -2
- package/src/AFilters/AFiltersHorizontal/AFiltersHorizontal.js +412 -396
- package/src/AFilters/AFiltersHorizontal/AFiltersHorizontalFilter/AFiltersHorizontalFilter.js +102 -99
- package/src/AFilters/AFiltersHorizontal/compositionAPI/FiltersSavedDeleteAPI.js +108 -108
- package/src/AFilters/AFiltersMain/AFiltersMain.js +114 -111
- package/src/AFilters/AFiltersSaveModal/compositionAPI/SaveAPI.js +65 -65
- package/src/ALinkCopy/ALinkCopy.js +98 -95
- package/src/ALinkCopy/compositionAPI/CopyAPI.js +48 -48
- package/src/AList/__tests__/AList.test.js +33 -33
- package/src/AList/compositionAPI/__tests__/TagAPI.test.js +43 -43
- package/src/AMenu/AMenu.js +4 -1
- package/src/AMenu/AMenuBreadcrumbs/AMenuBreadcrumbs.js +240 -237
- package/src/AMenu/AMenuPanelLink/AMenuPanelLink.js +4 -1
- package/src/AMenu/AMenuSearchPanelBreadcrumbs/AMenuSearchPanelBreadcrumbs.js +122 -119
- package/src/AModalWizard/AModalWizard.js +58 -53
- package/src/AModalWizard/compositionAPI/__tests__/ScrollAPI.test.js +46 -46
- package/src/APagination/APaginationPages/APaginationPages.js +15 -4
- package/src/ARate/ARate.js +254 -249
- package/src/ARate/ARateIcon/ADecimalIcon/ADecimalIcon.js +53 -50
- package/src/ARate/ARateIcon/ARateIcon.js +109 -104
- package/src/AResizer/AResizer.js +167 -162
- package/src/ATable/ATableHeaderTh/compositionAPI/SortAPI.js +172 -167
- package/src/ATable/ATableHeaderThAction/ATableHeaderThAction.js +14 -4
- package/src/ATable/ATableHeaderThAction/ATableHeaderThActionItem/ATableHeaderThActionItem.js +191 -184
- package/src/ATable/ATablePreviewDown/ATablePreviewDown.js +72 -69
- package/src/ATable/ATablePreviewRight/ATablePreviewRight.js +265 -258
- package/src/ATable/ATableSortingAdditional/ATableSortingAdditional.js +224 -219
- package/src/ATable/ATableSortingAdditional/__tests__/ATableSortingAdditional.AttributesAPI.test.js +39 -39
- package/src/ATable/ATableSortingAdditional/__tests__/ATableSortingAdditional.ColumnsAPI.test.js +68 -68
- package/src/ATable/ATableSortingAdditional/__tests__/ATableSortingAdditional.DropdownAPI.test.js +45 -45
- package/src/ATable/ATableSortingAdditional/__tests__/ATableSortingAdditional.FormAPI.test.js +95 -95
- package/src/ATable/ATableSortingAdditional/__tests__/ATableSortingAdditional.ModelAPI.test.js +1 -1
- package/src/ATable/ATableTd/ATableTd.js +4 -1
- package/src/ATable/ATableTdAction/ATableTdAction.js +19 -12
- package/src/ATable/ATableTopPanel/ATableTopPanel.js +11 -3
- package/src/ATable/ATableTr/ATableTr.js +408 -405
- package/src/ATable/__tests__/ATable.HeaderSlot.test.js +102 -97
- package/src/ATable/__tests__/ATable.RowIdsAPI.test.js +66 -66
- package/src/ATableForm/ATableForm.js +88 -85
- package/src/ATableForm/ATableFormCellAction/ATableFormCellAction.js +14 -4
- package/src/ATableForm/ATableFormCellDnd/ATableFormCellDnd.js +196 -187
- package/src/ATableForm/ATableFormRow/compositionAPI/EditAPI.js +104 -104
- package/src/ATableForm/__tests__/ATableForm.DragAndDropAPI.test.js +200 -212
- package/src/ATableForm/__tests__/ATableForm.ListView.test.js +134 -174
- package/src/ATableForm/compositionAPI/IconsAPI.js +24 -21
- package/src/AVerticalScroll/AVerticalScroll.js +182 -177
- package/src/AWizard/AWizard.js +26 -21
- package/src/AWizard/AWizardStep/AWizardStep.js +275 -270
- package/src/AWizard/compositionAPI/__tests__/ChangeStepAPI.test.js +32 -32
- package/src/AWizard/compositionAPI/__tests__/LocalAPI.test.js +55 -55
- package/src/PuxDatepicker/PuxDatepickerCalendarPanel/PuxDatepickerCalendarPanel.js +646 -648
- package/src/PuxDatepicker/panel/PanelDate/PanelDate.js +300 -301
- package/src/PuxDatepicker/panel/PanelMonth/PanelMonth.js +148 -149
- package/src/PuxDatepicker/panel/PanelTime/PanelTime.js +256 -257
- package/src/PuxDatepicker/panel/PanelYear/PanelYear.js +136 -137
- package/src/PuxDatepicker/utils/index.js +100 -100
- package/src/compositionAPI/AHttpAPI.js +593 -593
- package/src/compositionAPI/__tests__/AHttpAPI.test.js +42 -42
- package/src/filters/__tests__/filterBoolean.test.js +38 -38
- package/src/filters/__tests__/filterCapitalize.test.js +38 -38
- package/src/filters/__tests__/filterCurrency.test.js +21 -21
- package/src/filters/__tests__/filterDate.test.js +42 -42
- package/src/filters/__tests__/filterDefaultForEmpty.test.js +24 -24
- package/src/filters/__tests__/filterEmail.test.js +42 -42
- package/src/filters/__tests__/filterEscapeHtml.test.js +45 -45
- package/src/filters/__tests__/filterFileSize.test.js +45 -45
- package/src/filters/__tests__/filterFloat.test.js +74 -74
- package/src/filters/__tests__/filterJson.test.js +74 -74
- package/src/filters/__tests__/filterKeyValue.test.js +50 -50
- package/src/filters/__tests__/filterLimitTo.test.js +39 -39
- package/src/filters/__tests__/filterLink.test.js +41 -41
- package/src/filters/__tests__/filterList.test.js +149 -149
- package/src/filters/__tests__/filterLowerCase.test.js +38 -38
- package/src/filters/__tests__/filterMask.test.js +80 -80
- package/src/filters/__tests__/filterPropertyByValue.test.js +27 -27
- package/src/filters/__tests__/filterSearchHighlight.test.js +129 -129
- package/src/filters/__tests__/filterUpperCase.test.js +38 -38
- package/src/filters/__tests__/filterValueByCondition.test.js +3 -3
- package/src/filters/filterJson.js +39 -39
- package/src/filters/filterValueByCondition.js +2 -2
- package/src/plugins/AAlertPlugin.js +16 -5
- package/src/plugins/AMultiselectOrderedPlugin.js +88 -81
- package/src/plugins/ASelectPlugin.js +12 -10
- package/src/ui/ACheckbox/ACheckbox.js +82 -79
- package/src/ui/ADatepicker/compositionAPI/EventsAPI.js +297 -297
- package/src/ui/ADatepicker/utils/index.js +76 -76
- package/src/ui/ADatepickerAlt/ADatepicker.js +912 -912
- package/src/ui/ADatepickerAlt/utils/index.js +98 -98
- package/src/ui/AFieldset/__tests__/AFieldset.ClassColumn.test.js +113 -114
- package/src/ui/AFormElementBtnClear/AFormElementBtnClear.js +4 -1
- package/src/ui/AInputCurrency/AInputCurrency.js +20 -15
- package/src/ui/AInputCurrency/__tests__/AInputCurrency.ModelAPI.test.js +73 -73
- package/src/ui/AInputNumber/AInputNumber.js +17 -12
- package/src/ui/AJson/AJson.js +12 -3
- package/src/ui/AJson/compositionAPI/JsonAPI.js +116 -116
- package/src/ui/ALabel/__tests__/ALabel.IdAPI.test.js +42 -42
- package/src/ui/ALabel/__tests__/ALabel.LabelAPI.test.js +33 -33
- package/src/ui/ARadio/ARadio.js +80 -77
- package/src/ui/ASelect/ASelect.js +390 -383
- package/src/ui/ASelect/ASelectElement/ASelectElement.js +179 -176
- package/src/ui/ASelect/ASelectValueCloseable/ASelectValueCloseable.js +143 -141
- package/src/ui/ASelect/__tests__/SelectedFirstAPI.test.js +101 -101
- package/src/ui/ASelect/__tests__/SelectedVisibleAPI.test.js +98 -98
- package/src/ui/ASlider/compositionAPI/SliderAPI.js +23 -23
- package/src/ui/AValidatedJson/AValidatedJson.js +4 -1
- package/src/ui/AValidatedJson/AValidatedJsonItem/AValidatedJsonItem.js +308 -298
- package/src/ui/compositionApi/UiCollapseAPI.js +68 -63
- package/src/ui/compositionApi/UiInputAutofillAPI.js +41 -41
- package/src/ui/compositionApi/__tests__/UIDataGroupAPI.test.js +106 -106
- package/src/ui/compositionApi/__tests__/UIExcludeRenderAttributesAPI.test.js +39 -39
- package/src/ui/compositionApi/__tests__/UiDataWithKeyIdAndLabelAPI.test.js +128 -128
- package/src/ui/compositionApi/__tests__/UiSearchAPI.test.js +71 -71
- package/src/utils/EventBus.js +51 -8
- package/src/utils/__tests__/EventBus.test.js +138 -0
- package/src/utils/__tests__/utils.aOrderBy.test.js +1 -1
- package/src/utils/__tests__/utils.aSortBy.test.js +1 -1
- package/src/utils/__tests__/utils.getTotalNestedCount.test.js +56 -56
- package/src/utils/__tests__/utils.isArrayOfArrays.test.js +44 -44
- package/src/utils/__tests__/utils.isArrayOfStrings.test.js +36 -36
- package/src/utils/__tests__/utilsArray.aFirst.test.js +1 -1
- package/src/utils/__tests__/utilsArray.aLast.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isArguments.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isArray.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isArrayBuffer.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isBoolean.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isBuffer.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isDate.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isElement.test.js +5 -3
- package/src/utils/__tests__/utilsLang.isError.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isFinite.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isFunction.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isInteger.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isMap.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isNaN.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isNil.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isNull.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isNumber.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isObject.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isObjectLike.test.js +5 -3
- package/src/utils/__tests__/utilsLang.isPlainObject.test.js +3 -2
- package/src/utils/__tests__/utilsLang.isPromise.test.js +5 -2
- package/src/utils/__tests__/utilsLang.isRegExp.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isSet.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isString.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isSymbol.test.js +5 -3
- package/src/utils/__tests__/utilsLang.isUndefined.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isWeakMap.test.js +1 -1
- package/src/utils/__tests__/utilsLang.isWeakSet.test.js +1 -1
- package/src/utils/__tests__/utilsMath.isEven.test.js +43 -43
- package/src/utils/__tests__/utilsMath.isOdd.test.js +43 -43
- package/src/utils/__tests__/utilsUi.isModelForFilterNotEmpty.test.js +65 -65
- package/src/utils/autosize.js +1 -1
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
describe,
|
|
3
|
-
expect,
|
|
4
|
-
it,
|
|
5
|
-
} from "
|
|
6
|
-
|
|
7
|
-
import filterLink from "../filterLink";
|
|
8
|
-
|
|
9
|
-
describe("filterLink", () => {
|
|
10
|
-
it("default behavior", () => {
|
|
11
|
-
expect(filterLink("example.com")).toBe("<a href=\"https://example.com\">example.com</a>");
|
|
12
|
-
expect(filterLink("http://example.com")).toBe("<a href=\"http://example.com\">http://example.com</a>");
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it("with linkText", () => {
|
|
16
|
-
expect(filterLink("example.com", { linkText: "Example" })).toBe("<a href=\"https://example.com\">Example</a>");
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("with protocol", () => {
|
|
20
|
-
expect(filterLink("example.com", { protocol: "http://" })).toBe("<a href=\"http://example.com\">example.com</a>");
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("with target", () => {
|
|
24
|
-
expect(filterLink("example.com", { target: "_blank" })).toBe("<a href=\"https://example.com\" target=\"_blank\">example.com</a>");
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("with linkClass", () => {
|
|
28
|
-
expect(filterLink("example.com", { linkClass: "custom-class" })).toBe("<a href=\"https://example.com\" class=\"custom-class\">example.com</a>");
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("invalid URL", () => {
|
|
32
|
-
expect(filterLink(null)).toBe("");
|
|
33
|
-
expect(filterLink(undefined)).toBe("");
|
|
34
|
-
expect(filterLink(123)).toBe("");
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("combined options", () => {
|
|
38
|
-
expect(filterLink("example.com", { linkText: "Example", target: "_blank", linkClass: "custom-class" }))
|
|
39
|
-
.toBe("<a href=\"https://example.com\" target=\"_blank\" class=\"custom-class\">Example</a>");
|
|
40
|
-
});
|
|
41
|
-
});
|
|
1
|
+
import {
|
|
2
|
+
describe,
|
|
3
|
+
expect,
|
|
4
|
+
it,
|
|
5
|
+
} from "vitest";
|
|
6
|
+
|
|
7
|
+
import filterLink from "../filterLink";
|
|
8
|
+
|
|
9
|
+
describe("filterLink", () => {
|
|
10
|
+
it("default behavior", () => {
|
|
11
|
+
expect(filterLink("example.com")).toBe("<a href=\"https://example.com\">example.com</a>");
|
|
12
|
+
expect(filterLink("http://example.com")).toBe("<a href=\"http://example.com\">http://example.com</a>");
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("with linkText", () => {
|
|
16
|
+
expect(filterLink("example.com", { linkText: "Example" })).toBe("<a href=\"https://example.com\">Example</a>");
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("with protocol", () => {
|
|
20
|
+
expect(filterLink("example.com", { protocol: "http://" })).toBe("<a href=\"http://example.com\">example.com</a>");
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("with target", () => {
|
|
24
|
+
expect(filterLink("example.com", { target: "_blank" })).toBe("<a href=\"https://example.com\" target=\"_blank\">example.com</a>");
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("with linkClass", () => {
|
|
28
|
+
expect(filterLink("example.com", { linkClass: "custom-class" })).toBe("<a href=\"https://example.com\" class=\"custom-class\">example.com</a>");
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("invalid URL", () => {
|
|
32
|
+
expect(filterLink(null)).toBe("");
|
|
33
|
+
expect(filterLink(undefined)).toBe("");
|
|
34
|
+
expect(filterLink(123)).toBe("");
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("combined options", () => {
|
|
38
|
+
expect(filterLink("example.com", { linkText: "Example", target: "_blank", linkClass: "custom-class" }))
|
|
39
|
+
.toBe("<a href=\"https://example.com\" target=\"_blank\" class=\"custom-class\">Example</a>");
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -1,149 +1,149 @@
|
|
|
1
|
-
import {
|
|
2
|
-
describe,
|
|
3
|
-
expect,
|
|
4
|
-
it,
|
|
5
|
-
} from "
|
|
6
|
-
|
|
7
|
-
import filterList from "../filterList";
|
|
8
|
-
|
|
9
|
-
describe("filterList", () => {
|
|
10
|
-
it("isSimpleArray=true", () => {
|
|
11
|
-
expect(filterList(["label 1", "label 2", "label 3"])).toBe("<ul><li>label 1</li><li>label 2</li><li>label 3</li></ul>");
|
|
12
|
-
expect(filterList(["label 1", "label 2", "label 3"], { isSimpleArray: true })).toBe("<ul><li>label 1</li><li>label 2</li><li>label 3</li></ul>");
|
|
13
|
-
expect(filterList(["label 1"])).toBe("<ul><li>label 1</li></ul>");
|
|
14
|
-
expect(filterList([])).toBe("");
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it("keyLabel", () => {
|
|
18
|
-
const LIST = [
|
|
19
|
-
{ label: "label 1" },
|
|
20
|
-
{ label: "label 2" },
|
|
21
|
-
{ label: "label 3" },
|
|
22
|
-
{ label: "label 4" },
|
|
23
|
-
];
|
|
24
|
-
|
|
25
|
-
expect(filterList(LIST, { keyLabel: "label" })).toBe("<ul><li>label 1</li><li>label 2</li><li>label 3</li><li>label 4</li></ul>");
|
|
26
|
-
expect(filterList(LIST, { keyLabel: "aloha" })).toBe("<ul><li></li><li></li><li></li><li></li></ul>");
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it("keyLabelCallback", () => {
|
|
30
|
-
const LIST = [
|
|
31
|
-
{ label: "label 1" },
|
|
32
|
-
{ label: "label 2" },
|
|
33
|
-
{ label: "label 3" },
|
|
34
|
-
{ label: "label 4" },
|
|
35
|
-
];
|
|
36
|
-
|
|
37
|
-
const keyLabelCallback = ({ item }) => {
|
|
38
|
-
return `+ ${ item.label }`;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
expect(filterList(LIST, { keyLabelCallback })).toBe("<ul><li>+ label 1</li><li>+ label 2</li><li>+ label 3</li><li>+ label 4</li></ul>");
|
|
42
|
-
expect(filterList(LIST, { keyLabelCallback: () => "Aloha" })).toBe("<ul><li>Aloha</li><li>Aloha</li><li>Aloha</li><li>Aloha</li></ul>");
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("isHtml=false", () => {
|
|
46
|
-
expect(filterList(["label 1", "label 2", "label 3"], { isHtml: false })).toBe("label 1, label 2, label 3");
|
|
47
|
-
expect(filterList(["aloha"], { isHtml: false })).toBe("aloha");
|
|
48
|
-
expect(filterList(["x", "y", "z"], { isHtml: false })).toBe("x, y, z");
|
|
49
|
-
expect(filterList(123, { isHtml: false })).toBe("");
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("separator isHtml=false", () => {
|
|
53
|
-
expect(filterList(["label 1", "label 2", "label 3"], { isHtml: false, separator: "," })).toBe("label 1,label 2,label 3");
|
|
54
|
-
expect(filterList(["label 1", "label 2", "label 3"], { isHtml: false, separator: "; " })).toBe("label 1; label 2; label 3");
|
|
55
|
-
expect(filterList(["x", "y", "z"], { isHtml: false, separator: " - " })).toBe("x - y - z");
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("separator isHtml=true", () => {
|
|
59
|
-
expect(filterList(["label 1", "label 2", "label 3"], { isHtml: true, separator: "," })).toBe("<ul><li>label 1,</li><li>label 2,</li><li>label 3</li></ul>");
|
|
60
|
-
expect(filterList(["label 1", "label 2", "label 3"], { isHtml: true, separator: ";" })).toBe("<ul><li>label 1;</li><li>label 2;</li><li>label 3</li></ul>");
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("separatorHtml", () => {
|
|
64
|
-
expect(filterList(["label 1", "label 2", "label 3"], { isHtml: true, separatorHtml: "<hr>" })).toBe("<ul><li>label 1<hr></li><li>label 2<hr></li><li>label 3</li></ul>");
|
|
65
|
-
expect(filterList(["label 1", "label 2", "label 3"], { isHtml: true, separatorHtml: "<div>Aloha</div>" })).toBe("<ul><li>label 1<div>Aloha</div></li><li>label 2<div>Aloha</div></li><li>label 3</li></ul>");
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it("tag", () => {
|
|
69
|
-
expect(filterList(["label 1", "label 2", "label 3"], { tag: "ul" })).toBe("<ul><li>label 1</li><li>label 2</li><li>label 3</li></ul>");
|
|
70
|
-
expect(filterList(["label 1", "label 2", "label 3"], { tag: "ol" })).toBe("<ol><li>label 1</li><li>label 2</li><li>label 3</li></ol>");
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it("listClass", () => {
|
|
74
|
-
expect(filterList(["label 1", "label 2", "label 3"], { listClass: "test" })).toBe("<ul class=\"test\"><li>label 1</li><li>label 2</li><li>label 3</li></ul>");
|
|
75
|
-
expect(filterList(["label 1", "label 2", "label 3"], { listClass: "a_list_without_styles" })).toBe("<ul class=\"a_list_without_styles\"><li>label 1</li><li>label 2</li><li>label 3</li></ul>");
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it("keyChildren", () => {
|
|
79
|
-
const LIST = [
|
|
80
|
-
{
|
|
81
|
-
label: "Level 1",
|
|
82
|
-
children: [
|
|
83
|
-
{
|
|
84
|
-
label: "Level 1.1",
|
|
85
|
-
children: [
|
|
86
|
-
{
|
|
87
|
-
label: "Level 1.1.1",
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
label: "Level 1.1.2",
|
|
91
|
-
},
|
|
92
|
-
],
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
label: "Level 1.2",
|
|
96
|
-
},
|
|
97
|
-
],
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
label: "Level 2",
|
|
101
|
-
children: [
|
|
102
|
-
{
|
|
103
|
-
label: "Level 2.1",
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
label: "Level 2.2",
|
|
107
|
-
},
|
|
108
|
-
],
|
|
109
|
-
},
|
|
110
|
-
];
|
|
111
|
-
|
|
112
|
-
expect(filterList(LIST, {
|
|
113
|
-
keyLabel: "label",
|
|
114
|
-
keyChildren: "children",
|
|
115
|
-
})).toBe("<ul><li>Level 1<ul><li>Level 1.1<ul><li>Level 1.1.1</li><li>Level 1.1.2</li></ul></li><li>Level 1.2</li></ul></li><li>Level 2<ul><li>Level 2.1</li><li>Level 2.2</li></ul></li></ul>");
|
|
116
|
-
expect(filterList(LIST, {
|
|
117
|
-
keyLabel: "label",
|
|
118
|
-
keyChildren: "children",
|
|
119
|
-
listClass: "a_list_without_styles",
|
|
120
|
-
})).toBe("<ul class=\"a_list_without_styles\"><li>Level 1<ul class=\"a_list_without_styles\"><li>Level 1.1<ul class=\"a_list_without_styles\"><li>Level 1.1.1</li><li>Level 1.1.2</li></ul></li><li>Level 1.2</li></ul></li><li>Level 2<ul class=\"a_list_without_styles\"><li>Level 2.1</li><li>Level 2.2</li></ul></li></ul>");
|
|
121
|
-
expect(filterList(LIST, {
|
|
122
|
-
keyLabel: "label",
|
|
123
|
-
keyChildren: "children",
|
|
124
|
-
tag: "ol",
|
|
125
|
-
})).toBe("<ol><li>Level 1<ol><li>Level 1.1<ol><li>Level 1.1.1</li><li>Level 1.1.2</li></ol></li><li>Level 1.2</li></ol></li><li>Level 2<ol><li>Level 2.1</li><li>Level 2.2</li></ol></li></ol>");
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it("tree isSimpleArray=true", () => {
|
|
129
|
-
const LIST = ["Level 1", ["Level 2", ["Level 2.1", "Level 2.2"]], ["Level 3", ["Level 3.1", ["Level 3.2", ["Level 3.2.1", "Level 3.2.2"]]]]];
|
|
130
|
-
|
|
131
|
-
expect(filterList(LIST, { isSimpleArray: true })).toBe("<ul><li>Level 1</li><li>Level 2<ul><li>Level 2.1</li><li>Level 2.2</li></ul></li><li>Level 3<ul><li>Level 3.1</li><li>Level 3.2<ul><li>Level 3.2.1</li><li>Level 3.2.2</li></ul></li></ul></li></ul>");
|
|
132
|
-
|
|
133
|
-
expect(filterList(LIST, {
|
|
134
|
-
isSimpleArray: true,
|
|
135
|
-
listClass: "a_list_without_styles",
|
|
136
|
-
})).toBe("<ul class=\"a_list_without_styles\"><li>Level 1</li><li>Level 2<ul class=\"a_list_without_styles\"><li>Level 2.1</li><li>Level 2.2</li></ul></li><li>Level 3<ul class=\"a_list_without_styles\"><li>Level 3.1</li><li>Level 3.2<ul class=\"a_list_without_styles\"><li>Level 3.2.1</li><li>Level 3.2.2</li></ul></li></ul></li></ul>");
|
|
137
|
-
|
|
138
|
-
expect(filterList(LIST, {
|
|
139
|
-
isSimpleArray: true,
|
|
140
|
-
tag: "ol",
|
|
141
|
-
})).toBe("<ol><li>Level 1</li><li>Level 2<ol><li>Level 2.1</li><li>Level 2.2</li></ol></li><li>Level 3<ol><li>Level 3.1</li><li>Level 3.2<ol><li>Level 3.2.1</li><li>Level 3.2.2</li></ol></li></ol></li></ol>");
|
|
142
|
-
|
|
143
|
-
expect(filterList([["x1", ["x1.1", "x1.2"]]], { isSimpleArray: true })).toBe("<ul><li>x1<ul><li>x1.1</li><li>x1.2</li></ul></li></ul>");
|
|
144
|
-
|
|
145
|
-
expect(filterList(["x0", ["x1", ["x1.1", "x1.2"]], "x3"], { isSimpleArray: true })).toBe("<ul><li>x0</li><li>x1<ul><li>x1.1</li><li>x1.2</li></ul></li><li>x3</li></ul>");
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
|
|
1
|
+
import {
|
|
2
|
+
describe,
|
|
3
|
+
expect,
|
|
4
|
+
it,
|
|
5
|
+
} from "vitest";
|
|
6
|
+
|
|
7
|
+
import filterList from "../filterList";
|
|
8
|
+
|
|
9
|
+
describe("filterList", () => {
|
|
10
|
+
it("isSimpleArray=true", () => {
|
|
11
|
+
expect(filterList(["label 1", "label 2", "label 3"])).toBe("<ul><li>label 1</li><li>label 2</li><li>label 3</li></ul>");
|
|
12
|
+
expect(filterList(["label 1", "label 2", "label 3"], { isSimpleArray: true })).toBe("<ul><li>label 1</li><li>label 2</li><li>label 3</li></ul>");
|
|
13
|
+
expect(filterList(["label 1"])).toBe("<ul><li>label 1</li></ul>");
|
|
14
|
+
expect(filterList([])).toBe("");
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("keyLabel", () => {
|
|
18
|
+
const LIST = [
|
|
19
|
+
{ label: "label 1" },
|
|
20
|
+
{ label: "label 2" },
|
|
21
|
+
{ label: "label 3" },
|
|
22
|
+
{ label: "label 4" },
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
expect(filterList(LIST, { keyLabel: "label" })).toBe("<ul><li>label 1</li><li>label 2</li><li>label 3</li><li>label 4</li></ul>");
|
|
26
|
+
expect(filterList(LIST, { keyLabel: "aloha" })).toBe("<ul><li></li><li></li><li></li><li></li></ul>");
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("keyLabelCallback", () => {
|
|
30
|
+
const LIST = [
|
|
31
|
+
{ label: "label 1" },
|
|
32
|
+
{ label: "label 2" },
|
|
33
|
+
{ label: "label 3" },
|
|
34
|
+
{ label: "label 4" },
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
const keyLabelCallback = ({ item }) => {
|
|
38
|
+
return `+ ${ item.label }`;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
expect(filterList(LIST, { keyLabelCallback })).toBe("<ul><li>+ label 1</li><li>+ label 2</li><li>+ label 3</li><li>+ label 4</li></ul>");
|
|
42
|
+
expect(filterList(LIST, { keyLabelCallback: () => "Aloha" })).toBe("<ul><li>Aloha</li><li>Aloha</li><li>Aloha</li><li>Aloha</li></ul>");
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("isHtml=false", () => {
|
|
46
|
+
expect(filterList(["label 1", "label 2", "label 3"], { isHtml: false })).toBe("label 1, label 2, label 3");
|
|
47
|
+
expect(filterList(["aloha"], { isHtml: false })).toBe("aloha");
|
|
48
|
+
expect(filterList(["x", "y", "z"], { isHtml: false })).toBe("x, y, z");
|
|
49
|
+
expect(filterList(123, { isHtml: false })).toBe("");
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("separator isHtml=false", () => {
|
|
53
|
+
expect(filterList(["label 1", "label 2", "label 3"], { isHtml: false, separator: "," })).toBe("label 1,label 2,label 3");
|
|
54
|
+
expect(filterList(["label 1", "label 2", "label 3"], { isHtml: false, separator: "; " })).toBe("label 1; label 2; label 3");
|
|
55
|
+
expect(filterList(["x", "y", "z"], { isHtml: false, separator: " - " })).toBe("x - y - z");
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("separator isHtml=true", () => {
|
|
59
|
+
expect(filterList(["label 1", "label 2", "label 3"], { isHtml: true, separator: "," })).toBe("<ul><li>label 1,</li><li>label 2,</li><li>label 3</li></ul>");
|
|
60
|
+
expect(filterList(["label 1", "label 2", "label 3"], { isHtml: true, separator: ";" })).toBe("<ul><li>label 1;</li><li>label 2;</li><li>label 3</li></ul>");
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("separatorHtml", () => {
|
|
64
|
+
expect(filterList(["label 1", "label 2", "label 3"], { isHtml: true, separatorHtml: "<hr>" })).toBe("<ul><li>label 1<hr></li><li>label 2<hr></li><li>label 3</li></ul>");
|
|
65
|
+
expect(filterList(["label 1", "label 2", "label 3"], { isHtml: true, separatorHtml: "<div>Aloha</div>" })).toBe("<ul><li>label 1<div>Aloha</div></li><li>label 2<div>Aloha</div></li><li>label 3</li></ul>");
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("tag", () => {
|
|
69
|
+
expect(filterList(["label 1", "label 2", "label 3"], { tag: "ul" })).toBe("<ul><li>label 1</li><li>label 2</li><li>label 3</li></ul>");
|
|
70
|
+
expect(filterList(["label 1", "label 2", "label 3"], { tag: "ol" })).toBe("<ol><li>label 1</li><li>label 2</li><li>label 3</li></ol>");
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("listClass", () => {
|
|
74
|
+
expect(filterList(["label 1", "label 2", "label 3"], { listClass: "test" })).toBe("<ul class=\"test\"><li>label 1</li><li>label 2</li><li>label 3</li></ul>");
|
|
75
|
+
expect(filterList(["label 1", "label 2", "label 3"], { listClass: "a_list_without_styles" })).toBe("<ul class=\"a_list_without_styles\"><li>label 1</li><li>label 2</li><li>label 3</li></ul>");
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("keyChildren", () => {
|
|
79
|
+
const LIST = [
|
|
80
|
+
{
|
|
81
|
+
label: "Level 1",
|
|
82
|
+
children: [
|
|
83
|
+
{
|
|
84
|
+
label: "Level 1.1",
|
|
85
|
+
children: [
|
|
86
|
+
{
|
|
87
|
+
label: "Level 1.1.1",
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
label: "Level 1.1.2",
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
label: "Level 1.2",
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
label: "Level 2",
|
|
101
|
+
children: [
|
|
102
|
+
{
|
|
103
|
+
label: "Level 2.1",
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
label: "Level 2.2",
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
];
|
|
111
|
+
|
|
112
|
+
expect(filterList(LIST, {
|
|
113
|
+
keyLabel: "label",
|
|
114
|
+
keyChildren: "children",
|
|
115
|
+
})).toBe("<ul><li>Level 1<ul><li>Level 1.1<ul><li>Level 1.1.1</li><li>Level 1.1.2</li></ul></li><li>Level 1.2</li></ul></li><li>Level 2<ul><li>Level 2.1</li><li>Level 2.2</li></ul></li></ul>");
|
|
116
|
+
expect(filterList(LIST, {
|
|
117
|
+
keyLabel: "label",
|
|
118
|
+
keyChildren: "children",
|
|
119
|
+
listClass: "a_list_without_styles",
|
|
120
|
+
})).toBe("<ul class=\"a_list_without_styles\"><li>Level 1<ul class=\"a_list_without_styles\"><li>Level 1.1<ul class=\"a_list_without_styles\"><li>Level 1.1.1</li><li>Level 1.1.2</li></ul></li><li>Level 1.2</li></ul></li><li>Level 2<ul class=\"a_list_without_styles\"><li>Level 2.1</li><li>Level 2.2</li></ul></li></ul>");
|
|
121
|
+
expect(filterList(LIST, {
|
|
122
|
+
keyLabel: "label",
|
|
123
|
+
keyChildren: "children",
|
|
124
|
+
tag: "ol",
|
|
125
|
+
})).toBe("<ol><li>Level 1<ol><li>Level 1.1<ol><li>Level 1.1.1</li><li>Level 1.1.2</li></ol></li><li>Level 1.2</li></ol></li><li>Level 2<ol><li>Level 2.1</li><li>Level 2.2</li></ol></li></ol>");
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it("tree isSimpleArray=true", () => {
|
|
129
|
+
const LIST = ["Level 1", ["Level 2", ["Level 2.1", "Level 2.2"]], ["Level 3", ["Level 3.1", ["Level 3.2", ["Level 3.2.1", "Level 3.2.2"]]]]];
|
|
130
|
+
|
|
131
|
+
expect(filterList(LIST, { isSimpleArray: true })).toBe("<ul><li>Level 1</li><li>Level 2<ul><li>Level 2.1</li><li>Level 2.2</li></ul></li><li>Level 3<ul><li>Level 3.1</li><li>Level 3.2<ul><li>Level 3.2.1</li><li>Level 3.2.2</li></ul></li></ul></li></ul>");
|
|
132
|
+
|
|
133
|
+
expect(filterList(LIST, {
|
|
134
|
+
isSimpleArray: true,
|
|
135
|
+
listClass: "a_list_without_styles",
|
|
136
|
+
})).toBe("<ul class=\"a_list_without_styles\"><li>Level 1</li><li>Level 2<ul class=\"a_list_without_styles\"><li>Level 2.1</li><li>Level 2.2</li></ul></li><li>Level 3<ul class=\"a_list_without_styles\"><li>Level 3.1</li><li>Level 3.2<ul class=\"a_list_without_styles\"><li>Level 3.2.1</li><li>Level 3.2.2</li></ul></li></ul></li></ul>");
|
|
137
|
+
|
|
138
|
+
expect(filterList(LIST, {
|
|
139
|
+
isSimpleArray: true,
|
|
140
|
+
tag: "ol",
|
|
141
|
+
})).toBe("<ol><li>Level 1</li><li>Level 2<ol><li>Level 2.1</li><li>Level 2.2</li></ol></li><li>Level 3<ol><li>Level 3.1</li><li>Level 3.2<ol><li>Level 3.2.1</li><li>Level 3.2.2</li></ol></li></ol></li></ol>");
|
|
142
|
+
|
|
143
|
+
expect(filterList([["x1", ["x1.1", "x1.2"]]], { isSimpleArray: true })).toBe("<ul><li>x1<ul><li>x1.1</li><li>x1.2</li></ul></li></ul>");
|
|
144
|
+
|
|
145
|
+
expect(filterList(["x0", ["x1", ["x1.1", "x1.2"]], "x3"], { isSimpleArray: true })).toBe("<ul><li>x0</li><li>x1<ul><li>x1.1</li><li>x1.2</li></ul></li><li>x3</li></ul>");
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
describe,
|
|
3
|
-
expect,
|
|
4
|
-
it,
|
|
5
|
-
} from "
|
|
6
|
-
|
|
7
|
-
import filterLowerCase from "../filterLowerCase";
|
|
8
|
-
|
|
9
|
-
describe("filterLowerCase", () => {
|
|
10
|
-
it("should convert a string to lowercase", () => {
|
|
11
|
-
expect(filterLowerCase("--Foo-Bar--")).toBe("--foo-bar--");
|
|
12
|
-
expect(filterLowerCase("fooBar")).toBe("foobar");
|
|
13
|
-
expect(filterLowerCase("__FOO_BAR__")).toBe("__foo_bar__");
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it("should handle empty strings", () => {
|
|
17
|
-
expect(filterLowerCase("")).toBe("");
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it("should handle strings with no alphabetic characters", () => {
|
|
21
|
-
expect(filterLowerCase("12345")).toBe("12345");
|
|
22
|
-
expect(filterLowerCase("!@#$%")).toBe("!@#$%");
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("should handle mixed case strings", () => {
|
|
26
|
-
expect(filterLowerCase("FoObAr")).toBe("foobar");
|
|
27
|
-
expect(filterLowerCase("HELLOworld")).toBe("helloworld");
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("should handle strings with spaces", () => {
|
|
31
|
-
expect(filterLowerCase("Hello World")).toBe("hello world");
|
|
32
|
-
expect(filterLowerCase(" foo bar ")).toBe(" foo bar ");
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("should return the same string if already in lowercase", () => {
|
|
36
|
-
expect(filterLowerCase("already lowercase")).toBe("already lowercase");
|
|
37
|
-
});
|
|
38
|
-
});
|
|
1
|
+
import {
|
|
2
|
+
describe,
|
|
3
|
+
expect,
|
|
4
|
+
it,
|
|
5
|
+
} from "vitest";
|
|
6
|
+
|
|
7
|
+
import filterLowerCase from "../filterLowerCase";
|
|
8
|
+
|
|
9
|
+
describe("filterLowerCase", () => {
|
|
10
|
+
it("should convert a string to lowercase", () => {
|
|
11
|
+
expect(filterLowerCase("--Foo-Bar--")).toBe("--foo-bar--");
|
|
12
|
+
expect(filterLowerCase("fooBar")).toBe("foobar");
|
|
13
|
+
expect(filterLowerCase("__FOO_BAR__")).toBe("__foo_bar__");
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("should handle empty strings", () => {
|
|
17
|
+
expect(filterLowerCase("")).toBe("");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("should handle strings with no alphabetic characters", () => {
|
|
21
|
+
expect(filterLowerCase("12345")).toBe("12345");
|
|
22
|
+
expect(filterLowerCase("!@#$%")).toBe("!@#$%");
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("should handle mixed case strings", () => {
|
|
26
|
+
expect(filterLowerCase("FoObAr")).toBe("foobar");
|
|
27
|
+
expect(filterLowerCase("HELLOworld")).toBe("helloworld");
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("should handle strings with spaces", () => {
|
|
31
|
+
expect(filterLowerCase("Hello World")).toBe("hello world");
|
|
32
|
+
expect(filterLowerCase(" foo bar ")).toBe(" foo bar ");
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("should return the same string if already in lowercase", () => {
|
|
36
|
+
expect(filterLowerCase("already lowercase")).toBe("already lowercase");
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
import {
|
|
2
|
-
describe,
|
|
3
|
-
expect,
|
|
4
|
-
it,
|
|
5
|
-
} from "
|
|
6
|
-
|
|
7
|
-
import filterMask from "../filterMask";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
describe("filterMask", () => {
|
|
11
|
-
it("masks a credit card number, showing last 4 characters", () => {
|
|
12
|
-
const result = filterMask("1234567812345678", { chars: 4 });
|
|
13
|
-
expect(result).toBe("************5678");
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it("masks a phone number, showing last 3 characters", () => {
|
|
17
|
-
const result = filterMask("9876543210", { chars: 3 });
|
|
18
|
-
expect(result).toBe("*******210");
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("masks a number, showing last 4 characters", () => {
|
|
22
|
-
const result = filterMask(12345678, { chars: 4 });
|
|
23
|
-
expect(result).toBe("****5678");
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("masks a string with a different mask character", () => {
|
|
27
|
-
const result = filterMask("secretData", { chars: 3, mask: "#" });
|
|
28
|
-
expect(result).toBe("#######ata");
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("returns the original string if its length is less than or equal to chars", () => {
|
|
32
|
-
const result = filterMask("abc", { chars: 4 });
|
|
33
|
-
expect(result).toBe("abc");
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it("returns an empty string if the input is null", () => {
|
|
37
|
-
const result = filterMask(null);
|
|
38
|
-
expect(result).toBe("");
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it("returns an empty string if the input is undefined", () => {
|
|
42
|
-
const result = filterMask(undefined);
|
|
43
|
-
expect(result).toBe("");
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("converts non-string values to strings and masks them", () => {
|
|
47
|
-
const result = filterMask({ key: "value" }, { chars: 4 });
|
|
48
|
-
expect(result).toBe("***********ect]");
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it("handles empty string correctly", () => {
|
|
52
|
-
const result = filterMask("", { chars: 4 });
|
|
53
|
-
expect(result).toBe("");
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it("handles negative chars value by masking the entire string", () => {
|
|
57
|
-
const result = filterMask("12345678", { chars: -1 });
|
|
58
|
-
expect(result).toBe("********");
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("handles zero chars value by masking the entire string", () => {
|
|
62
|
-
const result = filterMask("12345678", { chars: 0 });
|
|
63
|
-
expect(result).toBe("********");
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it("handles large chars value by returning the original string", () => {
|
|
67
|
-
const result = filterMask("12345678", { chars: 10 });
|
|
68
|
-
expect(result).toBe("12345678");
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it("masks a boolean value correctly", () => {
|
|
72
|
-
const result = filterMask(true, { chars: 3 });
|
|
73
|
-
expect(result).toBe("*rue");
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it("masks an array value correctly", () => {
|
|
77
|
-
const result = filterMask([1, 2, 3, 4, 5], { chars: 3 });
|
|
78
|
-
expect(result).toBe("******4,5");
|
|
79
|
-
});
|
|
80
|
-
});
|
|
1
|
+
import {
|
|
2
|
+
describe,
|
|
3
|
+
expect,
|
|
4
|
+
it,
|
|
5
|
+
} from "vitest";
|
|
6
|
+
|
|
7
|
+
import filterMask from "../filterMask";
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
describe("filterMask", () => {
|
|
11
|
+
it("masks a credit card number, showing last 4 characters", () => {
|
|
12
|
+
const result = filterMask("1234567812345678", { chars: 4 });
|
|
13
|
+
expect(result).toBe("************5678");
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("masks a phone number, showing last 3 characters", () => {
|
|
17
|
+
const result = filterMask("9876543210", { chars: 3 });
|
|
18
|
+
expect(result).toBe("*******210");
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("masks a number, showing last 4 characters", () => {
|
|
22
|
+
const result = filterMask(12345678, { chars: 4 });
|
|
23
|
+
expect(result).toBe("****5678");
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("masks a string with a different mask character", () => {
|
|
27
|
+
const result = filterMask("secretData", { chars: 3, mask: "#" });
|
|
28
|
+
expect(result).toBe("#######ata");
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("returns the original string if its length is less than or equal to chars", () => {
|
|
32
|
+
const result = filterMask("abc", { chars: 4 });
|
|
33
|
+
expect(result).toBe("abc");
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("returns an empty string if the input is null", () => {
|
|
37
|
+
const result = filterMask(null);
|
|
38
|
+
expect(result).toBe("");
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("returns an empty string if the input is undefined", () => {
|
|
42
|
+
const result = filterMask(undefined);
|
|
43
|
+
expect(result).toBe("");
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("converts non-string values to strings and masks them", () => {
|
|
47
|
+
const result = filterMask({ key: "value" }, { chars: 4 });
|
|
48
|
+
expect(result).toBe("***********ect]");
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("handles empty string correctly", () => {
|
|
52
|
+
const result = filterMask("", { chars: 4 });
|
|
53
|
+
expect(result).toBe("");
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("handles negative chars value by masking the entire string", () => {
|
|
57
|
+
const result = filterMask("12345678", { chars: -1 });
|
|
58
|
+
expect(result).toBe("********");
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("handles zero chars value by masking the entire string", () => {
|
|
62
|
+
const result = filterMask("12345678", { chars: 0 });
|
|
63
|
+
expect(result).toBe("********");
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("handles large chars value by returning the original string", () => {
|
|
67
|
+
const result = filterMask("12345678", { chars: 10 });
|
|
68
|
+
expect(result).toBe("12345678");
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("masks a boolean value correctly", () => {
|
|
72
|
+
const result = filterMask(true, { chars: 3 });
|
|
73
|
+
expect(result).toBe("*rue");
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("masks an array value correctly", () => {
|
|
77
|
+
const result = filterMask([1, 2, 3, 4, 5], { chars: 3 });
|
|
78
|
+
expect(result).toBe("******4,5");
|
|
79
|
+
});
|
|
80
|
+
});
|