Skip to content
This repository was archived by the owner on Jan 2, 2023. It is now read-only.

Commit 63c260a

Browse files
committed
renamed test scenarios [still broken]
1 parent e504b83 commit 63c260a

1 file changed

Lines changed: 63 additions & 60 deletions

File tree

matcher.js

Lines changed: 63 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -55,39 +55,8 @@ const match = (payload, pattern) => {
5555
return result;
5656
}
5757

58-
const scenario_7 = () => {
5958

60-
const payload = {
61-
"type": "message",
62-
"text": "invite (Omar) (o@o.o) (foo) (batata)",
63-
"foo": { a: 1},
64-
}
65-
66-
const result = match(payload, {
67-
"type": "message",
68-
"text": /invite \((?<name>\S+)\) \((?<email>\S+)\) \((?<company>\S+)\) \((?<role>\S+)\)/,
69-
"foo": { a: 1},
70-
})
71-
72-
return JSON.stringify({
73-
match: true,
74-
total: 2,
75-
matches: {
76-
"type": "message",
77-
"text": "invite (Omar) (o@o.o) (foo) (batata)",
78-
"foo": { a: 1},
79-
},
80-
groups: {
81-
name: 'Omar',
82-
email: 'o@o.o',
83-
company: 'foo',
84-
role: 'batata'
85-
}
86-
}) == JSON.stringify(result);
87-
88-
}
89-
90-
const scenario_6 = () => {
59+
const test_nested_objects_in_arrays = () => {
9160
const payload = {
9261
"type": "message",
9362
"text": "invite (Omar) (o@o.o) (foo) (batata)",
@@ -122,17 +91,35 @@ const scenario_6 = () => {
12291

12392
return JSON.stringify({
12493
match: true,
125-
name: 'Omar',
126-
email: 'o@o.o',
127-
company: 'foo',
128-
role: 'batata',
129-
name_other: 'ayman',
130-
another: 'bassem',
131-
who: "mafsoum"
94+
total: 8,
95+
matches: {
96+
"type": "message",
97+
"text": "invite (Omar) (o@o.o) (foo) (batata)",
98+
"blocks": [
99+
{
100+
"number": 1,
101+
"bool": true,
102+
"items": ['ping ayman', 'hi bassem', 'sup yo']
103+
},{
104+
"number": 1,
105+
"bool": true,
106+
"some": "ping mafsoum"
107+
}
108+
]
109+
},
110+
groups: {
111+
name: 'Omar',
112+
email: 'o@o.o',
113+
company: 'foo',
114+
role: 'batata',
115+
name_other: 'ayman',
116+
another: 'bassem',
117+
who: "mafsoum"
118+
}
132119
}) == JSON.stringify(result);
133120
}
134121

135-
const scenario_5 = () => {
122+
const test_leaf_array_values_regex = () => {
136123
const payload = {
137124
"type": "message",
138125
"items": ['ping ayman', 'hi bassem', 'sup yo']
@@ -145,12 +132,19 @@ const scenario_5 = () => {
145132

146133
return JSON.stringify({
147134
match: true,
148-
name: 'ayman',
149-
another: 'bassem'
135+
total: 2,
136+
matches: {
137+
"type": "message",
138+
"items": ['ping ayman', 'hi bassem', 'sup yo']
139+
},
140+
groups: {
141+
name: 'ayman',
142+
another: 'bassem'
143+
}
150144
}) == JSON.stringify(result);
151145
}
152146

153-
const scenario_4 = () => {
147+
const test_leaf_array_values_multi_type = () => {
154148
const payload = {
155149
"type": "message",
156150
"items": [true, 'hi', 2, 3]
@@ -162,11 +156,16 @@ const scenario_4 = () => {
162156
})
163157

164158
return JSON.stringify({
165-
match: true
159+
match: true,
160+
total: 2,
161+
matches: {
162+
"type": "message",
163+
"items": [true, 'hi', 2, 3]
164+
}
166165
}) == JSON.stringify(result);
167166
}
168167

169-
const scenario_3 = () => {
168+
const test_leaf_array_values = () => {
170169
const payload = {
171170
"type": "message",
172171
"items": [0, 1, 2, 3]
@@ -178,11 +177,16 @@ const scenario_3 = () => {
178177
})
179178

180179
return JSON.stringify({
181-
match: true
180+
match: true,
181+
total: 2,
182+
matches: {
183+
"type": "message",
184+
"items": [0, 1, 2, 3]
185+
}
182186
}) == JSON.stringify(result);
183187
}
184188

185-
const scenario_2 = () => {
189+
const test_nested_objects = () => {
186190
const payload = {
187191
"type": "message",
188192
"text": "invite (Omar) (o@o.o) (foo) (batata)",
@@ -217,12 +221,12 @@ const scenario_2 = () => {
217221
matches: {
218222
type: 'message',
219223
text: 'invite (Omar) (o@o.o) (foo) (batata)',
220-
"blocka": {
224+
blocka: {
221225
"number": 1,
222226
"bool": true,
223227
"blockb": {
224-
"number": 1,
225-
"bool": true,
228+
"a": 1,
229+
"b": true,
226230
"foo": "hug me"
227231
}
228232
}
@@ -238,7 +242,7 @@ const scenario_2 = () => {
238242
}
239243

240244

241-
const scenario_1 = () => {
245+
const test_leaf_regex = () => {
242246

243247
const payload = {
244248
"type": "message",
@@ -267,7 +271,7 @@ const scenario_1 = () => {
267271

268272
}
269273

270-
const scenario_0 = () => {
274+
const test_leaf_values = () => {
271275

272276
const payload = {
273277
"type": "message",
@@ -302,13 +306,12 @@ const scenario_0 = () => {
302306

303307
module.exports = {
304308
tests: {
305-
scenario_0,
306-
scenario_1,
307-
scenario_2,
308-
// scenario_3,
309-
// scenario_4,
310-
// scenario_5,
311-
// scenario_6,
312-
scenario_7,
309+
test_leaf_values,
310+
test_leaf_regex,
311+
test_nested_objects,
312+
test_leaf_array_values,
313+
test_leaf_array_values_multi_type,
314+
test_leaf_array_values_regex,
315+
test_nested_objects_in_arrays,
313316
}
314317
}

0 commit comments

Comments
 (0)