1
- []
1
+ [
2
+ " Basic Checks" ,
3
+ {
4
+ "description" : " Two true values should be true" ,
5
+ "rule" : { "or" : [true , true ] },
6
+ "data" : null ,
7
+ "result" : true
8
+ },
9
+ {
10
+ "description" : " false or true should be true" ,
11
+ "rule" : { "or" : [false , true ] },
12
+ "data" : null ,
13
+ "result" : true
14
+ },
15
+ {
16
+ "description" : " true or false should be true" ,
17
+ "rule" : { "or" : [true , false ] },
18
+ "data" : null ,
19
+ "result" : true
20
+ },
21
+ {
22
+ "description" : " Two false values should be false" ,
23
+ "rule" : { "or" : [false , false ] },
24
+ "data" : null ,
25
+ "result" : false
26
+ },
27
+ {
28
+ "description" : " All true values should be true" ,
29
+ "rule" : { "or" : [true , true , true ] },
30
+ "data" : null ,
31
+ "result" : true
32
+ },
33
+ {
34
+ "description" : " Any true value should be true" ,
35
+ "rule" : { "or" : [true , true , false ] },
36
+ "data" : null ,
37
+ "result" : true
38
+ },
39
+ {
40
+ "description" : " Or with a single true value should be true" ,
41
+ "rule" : { "or" : [true ] },
42
+ "data" : null ,
43
+ "result" : true
44
+ },
45
+ {
46
+ "description" : " When all values are truthy, the first truthy value should be returned" ,
47
+ "rule" : { "or" : [1 , 2 , 3 ] },
48
+ "data" : null ,
49
+ "result" : 1
50
+ },
51
+ {
52
+ "description" : " When all values are truthy, the first truthy value should be returned (2)" ,
53
+ "rule" : { "or" : [true , 1 , {}] },
54
+ "data" : null ,
55
+ "result" : true
56
+ },
57
+ {
58
+ "description" : " Or with a single falsey value should be return the falsy value" ,
59
+ "rule" : { "or" : [[]] },
60
+ "data" : null ,
61
+ "result" : []
62
+ },
63
+ {
64
+ "description" : " Or with a single falsey value should be return the falsy value (2)" ,
65
+ "rule" : { "or" : [0 ] },
66
+ "data" : null ,
67
+ "result" : 0
68
+ },
69
+ {
70
+ "description" : " Or with a single falsey value should be return the falsy value (3)" ,
71
+ "rule" : { "or" : [" " ] },
72
+ "data" : null ,
73
+ "result" : " "
74
+ },
75
+ {
76
+ "description" : " Or with a single false value should be false" ,
77
+ "rule" : { "or" : [false ] },
78
+ "data" : null ,
79
+ "result" : false
80
+ },
81
+ {
82
+ "description" : " Or with 2 truthy values should return the first truthy value" ,
83
+ "rule" : { "or" : [1 , 3 ] },
84
+ "data" : null ,
85
+ "result" : 1
86
+ },
87
+ {
88
+ "description" : " Or with a truthy value and a false value should return the truthy value" ,
89
+ "rule" : { "or" : [3 , false ] },
90
+ "data" : null ,
91
+ "result" : 3
92
+ },
93
+ {
94
+ "description" : " Or with a truthy value and a false value should return the truthy value (2)" ,
95
+ "rule" : { "or" : [false , 3 ] },
96
+ "data" : null ,
97
+ "result" : 3
98
+ },
99
+ {
100
+ "description" : " Empty array is falsy, so it is not returned if the second argument is truthy" ,
101
+ "rule" : { "or" : [[], true ] },
102
+ "data" : null ,
103
+ "result" : true
104
+ },
105
+ {
106
+ "description" : " 0 is falsy, so it is not returned if the second argument is truthy" ,
107
+ "rule" : { "or" : [0 , true ] },
108
+ "data" : null ,
109
+ "result" : true
110
+ },
111
+ {
112
+ "description" : " Empty string is falsy, so it is not returned if the second argument is truthy" ,
113
+ "rule" : { "or" : [" " , true ] },
114
+ "data" : null ,
115
+ "result" : true
116
+ },
117
+ {
118
+ "description" : " 0 as a string is truthy, so the first truthy value is returned" ,
119
+ "rule" : { "or" : [" 0" , true ] },
120
+ "data" : null ,
121
+ "result" : " 0"
122
+ },
123
+ {
124
+ "description" : " Or with no arguments should return false" ,
125
+ "rule" : { "or" : [] },
126
+ "data" : null ,
127
+ "result" : false
128
+ },
129
+ " Valid Arguments Checks" ,
130
+ {
131
+ "description" : " Or with non-array arguments should throw" ,
132
+ "rule" : { "or" : true },
133
+ "data" : null ,
134
+ "error" : { "type" : " Invalid Arguments" }
135
+ },
136
+ " Short Circuiting Checks" ,
137
+ {
138
+ "description" : " Or will not interpret the second argument if the first is false" ,
139
+ "rule" : { "or" : [true , { "throw" : " Not Lazy" }] },
140
+ "data" : null ,
141
+ "result" : true
142
+ },
143
+ {
144
+ "description" : " Or will not interpret the second argument if the first is falsy" ,
145
+ "rule" : { "or" : [1 , { "throw" : " Not Lazy" }] },
146
+ "data" : null ,
147
+ "result" : 1
148
+ },
149
+ {
150
+ "description" : " Or will not interpret the nth argument if any value before it is false" ,
151
+ "rule" : { "or" : [false , 0 , null , { "val" : [] }, [], 4 , { "throw" : " Not Lazy" }] },
152
+ "data" : null ,
153
+ "result" : 4
154
+ }
155
+ ]
0 commit comments