@@ -14,6 +14,7 @@ describe('utils', () => {
14
14
context ( 'parseTitleGrep' , ( ) => {
15
15
it ( 'grabs the positive title' , ( ) => {
16
16
const parsed = parseTitleGrep ( 'hello w' )
17
+
17
18
expect ( parsed ) . to . deep . equal ( {
18
19
title : 'hello w' ,
19
20
invert : false ,
@@ -22,6 +23,7 @@ describe('utils', () => {
22
23
23
24
it ( 'trims the string' , ( ) => {
24
25
const parsed = parseTitleGrep ( ' hello w ' )
26
+
25
27
expect ( parsed ) . to . deep . equal ( {
26
28
title : 'hello w' ,
27
29
invert : false ,
@@ -30,6 +32,7 @@ describe('utils', () => {
30
32
31
33
it ( 'inverts the string' , ( ) => {
32
34
const parsed = parseTitleGrep ( '-hello w' )
35
+
33
36
expect ( parsed ) . to . deep . equal ( {
34
37
title : 'hello w' ,
35
38
invert : true ,
@@ -38,6 +41,7 @@ describe('utils', () => {
38
41
39
42
it ( 'trims the inverted the string' , ( ) => {
40
43
const parsed = parseTitleGrep ( ' -hello w ' )
44
+
41
45
expect ( parsed ) . to . deep . equal ( {
42
46
title : 'hello w' ,
43
47
invert : true ,
@@ -46,13 +50,15 @@ describe('utils', () => {
46
50
47
51
it ( 'returns null for undefined input' , ( ) => {
48
52
const parsed = parseTitleGrep ( )
53
+
49
54
expect ( parsed ) . to . equal ( null )
50
55
} )
51
56
} )
52
57
53
58
context ( 'parseFullTitleGrep' , ( ) => {
54
59
it ( 'returns list of title greps' , ( ) => {
55
60
const parsed = parseFullTitleGrep ( 'hello; one; -two' )
61
+
56
62
expect ( parsed ) . to . deep . equal ( [
57
63
{ title : 'hello' , invert : false } ,
58
64
{ title : 'one' , invert : false } ,
@@ -65,6 +71,7 @@ describe('utils', () => {
65
71
it ( 'parses AND tags' , ( ) => {
66
72
// run only the tests with all 3 tags
67
73
const parsed = parseTagsGrep ( '@tag1+@tag2+@tag3' )
74
+
68
75
expect ( parsed ) . to . deep . equal ( [
69
76
// single OR part
70
77
[
@@ -78,6 +85,7 @@ describe('utils', () => {
78
85
79
86
it ( 'handles dashes in the tag' , ( ) => {
80
87
const parsed = parseTagsGrep ( '@smoke+@screen-b' )
88
+
81
89
expect ( parsed ) . to . deep . equal ( [
82
90
[
83
91
{ tag : '@smoke' , invert : false } ,
@@ -89,6 +97,7 @@ describe('utils', () => {
89
97
it ( 'parses OR tags spaces' , ( ) => {
90
98
// run tests with tag1 OR tag2 or tag3
91
99
const parsed = parseTagsGrep ( '@tag1 @tag2 @tag3' )
100
+
92
101
expect ( parsed ) . to . deep . equal ( [
93
102
[ { tag : '@tag1' , invert : false } ] ,
94
103
[ { tag : '@tag2' , invert : false } ] ,
@@ -99,6 +108,7 @@ describe('utils', () => {
99
108
it ( 'parses OR tags commas' , ( ) => {
100
109
// run tests with tag1 OR tag2 or tag3
101
110
const parsed = parseTagsGrep ( '@tag1,@tag2,@tag3' )
111
+
102
112
expect ( parsed ) . to . deep . equal ( [
103
113
[ { tag : '@tag1' , invert : false } ] ,
104
114
[ { tag : '@tag2' , invert : false } ] ,
@@ -108,11 +118,13 @@ describe('utils', () => {
108
118
109
119
it ( 'parses inverted tag' , ( ) => {
110
120
const parsed = parseTagsGrep ( '-@tag1' )
121
+
111
122
expect ( parsed ) . to . deep . equal ( [ [ { tag : '@tag1' , invert : true } ] ] )
112
123
} )
113
124
114
125
it ( 'parses tag1 but not tag2 with space' , ( ) => {
115
126
const parsed = parseTagsGrep ( '@tag1 -@tag2' )
127
+
116
128
expect ( parsed ) . to . deep . equal ( [
117
129
[ { tag : '@tag1' , invert : false } ] ,
118
130
[ { tag : '@tag2' , invert : true } ] ,
@@ -121,6 +133,7 @@ describe('utils', () => {
121
133
122
134
it ( 'forgives extra spaces' , ( ) => {
123
135
const parsed = parseTagsGrep ( ' @tag1 -@tag2 ' )
136
+
124
137
expect ( parsed ) . to . deep . equal ( [
125
138
[ { tag : '@tag1' , invert : false } ] ,
126
139
[ { tag : '@tag2' , invert : true } ] ,
@@ -129,6 +142,7 @@ describe('utils', () => {
129
142
130
143
it ( 'parses tag1 but not tag2 with comma' , ( ) => {
131
144
const parsed = parseTagsGrep ( '@tag1,-@tag2' )
145
+
132
146
expect ( parsed ) . to . deep . equal ( [
133
147
[ { tag : '@tag1' , invert : false } ] ,
134
148
[ { tag : '@tag2' , invert : true } ] ,
@@ -137,15 +151,17 @@ describe('utils', () => {
137
151
138
152
it ( 'filters out empty tags' , ( ) => {
139
153
const parsed = parseTagsGrep ( ',, @tag1,-@tag2,, ,, ,' )
154
+
140
155
expect ( parsed ) . to . deep . equal ( [
141
156
[ { tag : '@tag1' , invert : false } ] ,
142
157
[ { tag : '@tag2' , invert : true } ] ,
143
158
] )
144
159
} )
145
160
146
- // would need to change the tokenizer
161
+ // TODO: would need to change the tokenizer
147
162
it . skip ( 'parses tag1 but not tag2' , ( ) => {
148
163
const parsed = parseTagsGrep ( '@tag1-@tag2' )
164
+
149
165
expect ( parsed ) . to . deep . equal ( [
150
166
[
151
167
{ tag : '@tag1' , invert : false } ,
@@ -156,8 +172,9 @@ describe('utils', () => {
156
172
157
173
it ( 'allows all tags to be inverted' , ( ) => {
158
174
const parsed = parseTagsGrep ( '--@tag1,--@tag2' )
175
+
159
176
expect ( parsed ) . to . deep . equal ( [
160
- [ { tag : '@tag1' , invert : true } , { tag : '@tag2' , invert : true } ]
177
+ [ { tag : '@tag1' , invert : true } , { tag : '@tag2' , invert : true } ] ,
161
178
] )
162
179
} )
163
180
} )
@@ -170,6 +187,7 @@ describe('utils', () => {
170
187
171
188
it ( 'creates just the title grep' , ( ) => {
172
189
const parsed = parseGrep ( 'hello w' )
190
+
173
191
expect ( parsed ) . to . deep . equal ( {
174
192
title : [
175
193
{
@@ -183,6 +201,7 @@ describe('utils', () => {
183
201
184
202
it ( 'creates object from the grep string only' , ( ) => {
185
203
const parsed = parseGrep ( 'hello w' )
204
+
186
205
expect ( parsed ) . to . deep . equal ( {
187
206
title : [
188
207
{
@@ -224,6 +243,7 @@ describe('utils', () => {
224
243
225
244
it ( 'creates object from the grep string and tags' , ( ) => {
226
245
const parsed = parseGrep ( 'hello w' , '@tag1+@tag2+@tag3' )
246
+
227
247
expect ( parsed ) . to . deep . equal ( {
228
248
title : [
229
249
{
@@ -251,6 +271,7 @@ describe('utils', () => {
251
271
expect (
252
272
shouldTestRun ( parsed , [ '@tag1' , '@tag2' , '@tag3' , '@tag4' ] ) ,
253
273
) . to . equal ( true )
274
+
254
275
// title matches, but tags do not
255
276
expect ( shouldTestRun ( parsed , 'hello w' , [ '@tag1' , '@tag2' ] ) ) . to . equal (
256
277
false ,
@@ -269,6 +290,7 @@ describe('utils', () => {
269
290
// our parsing and decision logic computes the expected result
270
291
const shouldIt = ( used , tags , expected ) => {
271
292
const parsedTags = parseTagsGrep ( used )
293
+
272
294
expect (
273
295
shouldTestRunTags ( parsedTags , tags ) ,
274
296
`"${ used } " against "${ tags } "` ,
@@ -308,36 +330,42 @@ describe('utils', () => {
308
330
// and apply the first argument in shouldTestRun
309
331
const checkName = ( grep , grepTags ) => {
310
332
const parsed = parseGrep ( grep , grepTags )
333
+
311
334
expect ( parsed ) . to . be . an ( 'object' )
312
335
313
336
return ( testName , testTags = [ ] ) => {
314
337
expect ( testName , 'test title' ) . to . be . a ( 'string' )
315
338
expect ( testTags , 'test tags' ) . to . be . an ( 'array' )
339
+
316
340
return shouldTestRun ( parsed , testName , testTags )
317
341
}
318
342
}
319
343
320
344
it ( 'simple tag' , ( ) => {
321
345
const parsed = parseGrep ( '@tag1' )
346
+
322
347
expect ( shouldTestRun ( parsed , 'no tag1 here' ) ) . to . be . false
323
348
expect ( shouldTestRun ( parsed , 'has @tag1 in the name' ) ) . to . be . true
324
349
} )
325
350
326
351
it ( 'with invert title' , ( ) => {
327
352
const t = checkName ( '-hello' )
353
+
328
354
expect ( t ( 'no greetings' ) ) . to . be . true
329
355
expect ( t ( 'has hello world' ) ) . to . be . false
330
356
} )
331
357
332
358
it ( 'with invert option' , ( ) => {
333
359
const t = checkName ( null , '-@tag1' )
360
+
334
361
expect ( t ( 'no tags here' ) ) . to . be . true
335
362
expect ( t ( 'has tag1' , [ '@tag1' ] ) ) . to . be . false
336
363
expect ( t ( 'has other tags' , [ '@tag2' ] ) ) . to . be . true
337
364
} )
338
365
339
366
it ( 'with AND option' , ( ) => {
340
367
const t = checkName ( '' , '@tag1+@tag2' )
368
+
341
369
expect ( t ( 'no tag1 here' ) ) . to . be . false
342
370
expect ( t ( 'has only @tag1' , [ '@tag1' ] ) ) . to . be . false
343
371
expect ( t ( 'has only @tag2' , [ '@tag2' ] ) ) . to . be . false
@@ -346,20 +374,23 @@ describe('utils', () => {
346
374
347
375
it ( 'with OR option' , ( ) => {
348
376
const t = checkName ( null , '@tag1 @tag2' )
377
+
349
378
expect ( t ( 'no tag1 here' ) ) . to . be . false
350
379
expect ( t ( 'has only @tag1 in the name' , [ '@tag1' ] ) ) . to . be . true
351
380
expect ( t ( 'has only @tag2 in the name' , [ '@tag2' ] ) ) . to . be . true
352
381
expect ( t ( 'has @tag1 and @tag2 in the name' , [ '@tag1' , '@tag2' ] ) ) . to . be
353
- . true
382
+ . true
354
383
} )
355
384
356
385
it ( 'OR with AND option' , ( ) => {
357
386
const t = checkName ( null , '@tag1 @tag2+@tag3' )
387
+
358
388
expect ( t ( 'no tag1 here' ) ) . to . be . false
359
389
expect ( t ( 'has only @tag1 in the name' , [ '@tag1' ] ) ) . to . be . true
360
390
expect ( t ( 'has only @tag2 in the name' , [ '@tag2' ] ) ) . to . be . false
361
391
expect ( t ( 'has only @tag2 in the name and also @tag3' , [ '@tag2' , '@tag3' ] ) )
362
- . to . be . true
392
+ . to . be . true
393
+
363
394
expect (
364
395
t ( 'has @tag1 and @tag2 and @tag3 in the name' , [
365
396
'@tag1' ,
@@ -371,8 +402,9 @@ describe('utils', () => {
371
402
372
403
it ( 'Multiple invert strings and a simple one' , ( ) => {
373
404
const t = checkName ( '-name;-hey;number' )
405
+
374
406
expect ( t ( 'number should only be matches without a n-a-m-e' ) ) . to . be . true
375
- expect ( t ( " number can't be name" ) ) . to . be . false
407
+ expect ( t ( ' number can\ 't be name' ) ) . to . be . false
376
408
expect ( t ( 'The man needs a name' ) ) . to . be . false
377
409
expect ( t ( 'number hey name' ) ) . to . be . false
378
410
expect ( t ( 'numbers hey name' ) ) . to . be . false
@@ -382,15 +414,17 @@ describe('utils', () => {
382
414
383
415
it ( 'Only inverted strings' , ( ) => {
384
416
const t = checkName ( '-name;-hey' )
385
- expect ( t ( "I'm matched" ) ) . to . be . true
386
- expect ( t ( "hey! I'm not" ) ) . to . be . false
417
+
418
+ expect ( t ( 'I\'m matched' ) ) . to . be . true
419
+ expect ( t ( 'hey! I\'m not' ) ) . to . be . false
387
420
expect ( t ( 'My name is weird' ) ) . to . be . false
388
421
} )
389
422
} )
390
423
391
424
context ( 'parseFullTitleGrep' , ( ) => {
392
425
const shouldIt = ( search , testName , expected ) => {
393
426
const parsed = parseFullTitleGrep ( search )
427
+
394
428
expect (
395
429
shouldTestRunTitle ( parsed , testName ) ,
396
430
`"${ search } " against title "${ testName } "` ,
0 commit comments