-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
133 lines (131 loc) · 4.22 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
const findCombinationsFromText = require("./solution");
describe("find Combinations From Text function Test", () => {
test("reguler case test 1", () => {
let actual = findCombinationsFromText(
"Group_Electric-Pallet-Jack-Parts, Category_Switches,Subcategory_Ignition-Switch"
);
expect(actual).toEqual(expectedResults[0]);
});
test("sepreated by key words test 2", () => {
let actual = findCombinationsFromText(
"--Group_Electric-Pallet-Jack-Parts, Category_Switche@%s-!!Subcategory_Ignition-Switch))@!%"
);
expect(actual).toEqual(expectedResults[1]);
});
test("Combinations needs to sort by the valid prifex level 3", () => {
let actual = findCombinationsFromText(
"Category_Switches-Group_Electric-Pallet-Jack-PartsSubcategory_Ignition-Switch"
);
expect(actual).toEqual(expectedResults[2]);
});
test("Make should always come after Subcategory, but if the Subcategory does not exist, Make comes after the Category test 4", () => {
let actual = findCombinationsFromText(
"Group_Tools-Hardware-Category_Roll-Pin-Make_Atlas"
);
expect(actual).toEqual(expectedResults[3]);
});
test("Invalid Combinations threason that there is tow Groups test 5", () => {
let actual = findCombinationsFromText(
"Group_Tools-Hardware-Category_Roll-Pin-Make_AtlasGroup_Test"
);
expect(actual).toEqual(expectedResults[4]);
});
test("Invalid Combinations Invalid Tag test 6", () => {
let actual = findCombinationsFromText(
"Group_Tools-Hardware-Category_Roll-Pin-Make_AtlasWrongPrefix_Test"
);
expect(actual).toEqual(expectedResults[5]);
});
test("Invalid Combinations threason that there is tow Groups test 7", () => {
let actual = findCombinationsFromText(
"Group_Tools-Hardware-Category_Roll-Pin-Make_U-LineModel_H-1193"
);
expect(actual).toEqual(expectedResults[6]);
});
test("Regular Combinations Case test test 8", () => {
let actual = findCombinationsFromText(
"Group_Tools-Hardware-Category_Roll-Pin-Make_MultitonModel_J"
);
expect(actual).toEqual(expectedResults[7]);
});
test("Regular Combinations Case test 9", () => {
let actual = findCombinationsFromText(
"Group_Tools-Hardware-Category_Roll-Pin-Make_MultitonModel_J"
);
expect(actual).toEqual(expectedResults[8]);
});
test("Regular Combinations Case test 10", () => {
let actual = findCombinationsFromText("Group_Tools-&-Hardware");
expect(actual).toEqual(expectedResults[9]);
});
});
const expectedResults = [
[
[
"Group_Electric-Pallet-Jack-Parts",
"Category_Switches",
"Subcategory_Ignition-Switch",
],
["Group_Electric-Pallet-Jack-Parts", "Category_Switches"],
["Group_Electric-Pallet-Jack-Parts"],
],
[
[
"Group_Electric-Pallet-Jack-Parts",
"Category_Switches",
"Subcategory_Ignition-Switch",
],
["Group_Electric-Pallet-Jack-Parts", "Category_Switches"],
["Group_Electric-Pallet-Jack-Parts"],
],
[
[
"Group_Electric-Pallet-Jack-Parts",
"Category_Switches",
"Subcategory_Ignition-Switch",
],
["Group_Electric-Pallet-Jack-Parts", "Category_Switches"],
["Group_Electric-Pallet-Jack-Parts"],
],
[
["Group_Tools-Hardware", "Category_Roll-Pin", "Make_Atlas"],
["Group_Tools-Hardware", "Category_Roll-Pin"],
["Group_Tools-Hardware"],
],
[],
[],
[
[
"Group_Tools-Hardware",
"Category_Roll-Pin",
"Make_U-LineModel_H-1193",
"Model_H-1193",
],
["Group_Tools-Hardware", "Category_Roll-Pin", "Make_U-LineModel_H-1193"],
["Group_Tools-Hardware", "Category_Roll-Pin"],
["Group_Tools-Hardware"],
],
[
[
"Group_Tools-Hardware",
"Category_Roll-Pin",
"Make_MultitonModel_J",
"Model_J",
],
["Group_Tools-Hardware", "Category_Roll-Pin", "Make_MultitonModel_J"],
["Group_Tools-Hardware", "Category_Roll-Pin"],
["Group_Tools-Hardware"],
],
[
[
"Group_Tools-Hardware",
"Category_Roll-Pin",
"Make_MultitonModel_J",
"Model_J",
],
["Group_Tools-Hardware", "Category_Roll-Pin", "Make_MultitonModel_J"],
["Group_Tools-Hardware", "Category_Roll-Pin"],
["Group_Tools-Hardware"],
],
[["Group_Tools-Hardware"]],
];