forked from duckduckgo/zeroclickinfo-goodies
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathColorPicker.t
264 lines (250 loc) · 13.7 KB
/
ColorPicker.t
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use Test::Deep;
use DDG::Test::Goodie;
zci answer_type => 'color_picker';
zci is_cached => 1;
# Build a structured answer that should match the response from the
# Perl file.
my $goodie_version = $DDG::GoodieBundle::OpenSourceDuckDuckGo::VERSION // 999;
sub build_structured_answer {
my $color = shift;
my $path = "/share/goodie/color_picker/$goodie_version/";
return 'Color Picker',
structured_answer => {
data => {
color => $color,
saturation_value_path => "${path}saturation_value_gradient.png",
hue_path => "${path}hue_gradient.png"
},
templates => {
group => 'text',
options => {
content => "DDH.color_picker.content"
}
}
};
}
# Use this to build expected results for your tests.
sub build_test { test_zci(build_structured_answer(@_)) }
ddg_goodie_test(
[qw( DDG::Goodie::ColorPicker )],
# Testing no color mentioned
'colorpicker' => build_test(undef),
'color picker' => build_test(undef),
'colourpicker' => build_test(undef),
'colour picker' => build_test(undef),
'rgb to hex' => build_test(undef),
'rgb to hex converter' => build_test(undef),
'rgb to hex conversion' => build_test(undef),
'rgb to hsv' => build_test(undef),
'rgb to hsv converter' => build_test(undef),
'rgb to hsv conversion' => build_test(undef),
'rgb to cmyk' => build_test(undef),
'rgb to cmyk converter' => build_test(undef),
'rgb to cmyk conversion' => build_test(undef),
'hex to rgb' => build_test(undef),
'hex to rgb converter' => build_test(undef),
'hex to rgb conversion' => build_test(undef),
'hex to hsv' => build_test(undef),
'hex to hsv converter' => build_test(undef),
'hex to hsv conversion' => build_test(undef),
'hex to cmyk' => build_test(undef),
'hex to cmyk converter' => build_test(undef),
'hex to cmyk conversion' => build_test(undef),
'hsv to rgb' => build_test(undef),
'hsv to rgb converter' => build_test(undef),
'hsv to rgb conversion' => build_test(undef),
'hsv to hex' => build_test(undef),
'hsv to hex converter' => build_test(undef),
'hsv to hex conversion' => build_test(undef),
'hsv to cmyk' => build_test(undef),
'hsv to cmyk converter' => build_test(undef),
'hsv to cmyk conversion' => build_test(undef),
'cmyk to rgb' => build_test(undef),
'cmyk to rgb converter' => build_test(undef),
'cmyk to rgb conversion' => build_test(undef),
'cmyk to hex' => build_test(undef),
'cmyk to hex converter' => build_test(undef),
'cmyk to hex conversion' => build_test(undef),
'cmyk to hsv' => build_test(undef),
'cmyk to hsv converter' => build_test(undef),
'cmyk to hsv conversion' => build_test(undef),
# Testing Hex Color Codes Full
'colorpicker #474747' => build_test('#474747'),
'color picker #474747' => build_test('#474747'),
'colourpicker #474747' => build_test('#474747'),
'colour picker #474747' => build_test('#474747'),
'hex to rgb #474747' => build_test('#474747'),
'hex to rgb converter #474747' => build_test('#474747'),
'hex to rgb #474747 converter' => build_test('#474747'),
'hex to hsv #474747' => build_test('#474747'),
'hex to hsv converter #474747' => build_test('#474747'),
'hex to hsv #474747 converter' => build_test('#474747'),
'hex to cmyk #474747' => build_test('#474747'),
'hex to cmyk converter #474747' => build_test('#474747'),
'hex to cmyk #474747 converter' => build_test('#474747'),
'hex to rgb color #474747' => build_test('#474747'),
'hex to rgb colour #474747' => build_test('#474747'),
'hex to hsv color #474747' => build_test('#474747'),
'hex to hsv colour #474747' => build_test('#474747'),
'hex to cmyk color #474747' => build_test('#474747'),
'hex to cmyk colour #474747' => build_test('#474747'),
'hex to rgb #474747 color' => build_test('#474747'),
'hex to rgb #474747 colour' => build_test('#474747'),
'hex to hsv #474747 color' => build_test('#474747'),
'hex to hsv #474747 colour' => build_test('#474747'),
'hex to cmyk #474747 color' => build_test('#474747'),
'hex to cmyk #474747 colour' => build_test('#474747'),
'hex to rgb conversion #474747' => build_test('#474747'),
'hex to rgb #474747 conversion' => build_test('#474747'),
'hex to hsv conversion #474747' => build_test('#474747'),
'hex to hsv #474747 conversion' => build_test('#474747'),
'hex to cmyk #474747' => build_test('#474747'),
'hex to cmyk conversion #474747' => build_test('#474747'),
'hex to cmyk #474747 conversion' => build_test('#474747'),
# Testing Hex Color Shorthand
'colorpicker #474' => build_test('#474'),
'color picker #474' => build_test('#474'),
'colourpicker #474' => build_test('#474'),
'colour picker #474' => build_test('#474'),
'hex to rgb #474' => build_test('#474'),
'hex to rgb converter #474' => build_test('#474'),
'hex to rgb #474 converter' => build_test('#474'),
'hex to hsv #474' => build_test('#474'),
'hex to hsv converter #474' => build_test('#474'),
'hex to hsv #474 converter' => build_test('#474'),
'hex to cmyk #474' => build_test('#474'),
'hex to cmyk converter #474' => build_test('#474'),
'hex to cmyk #474 converter' => build_test('#474'),
'hex to rgb color #474' => build_test('#474'),
'hex to rgb colour #474' => build_test('#474'),
'hex to hsv color #474' => build_test('#474'),
'hex to hsv colour #474' => build_test('#474'),
'hex to cmyk color #474' => build_test('#474'),
'hex to cmyk colour #474' => build_test('#474'),
'hex to rgb #474 color' => build_test('#474'),
'hex to rgb #474 colour' => build_test('#474'),
'hex to hsv #474 color' => build_test('#474'),
'hex to hsv #474 colour' => build_test('#474'),
'hex to cmyk #474 color' => build_test('#474'),
'hex to cmyk #474 colour' => build_test('#474'),
'hex to rgb conversion #474' => build_test('#474'),
'hex to rgb #474 conversion' => build_test('#474'),
'hex to hsv conversion #474' => build_test('#474'),
'hex to hsv #474 conversion' => build_test('#474'),
'hex to cmyk conversion #474' => build_test('#474'),
'hex to cmyk #474 conversion' => build_test('#474'),
# Testing RGB
'colorpicker rgb(240,100,141)' => build_test('rgb,240,100,141'),
'color picker rgb(240,100,141)' => build_test('rgb,240,100,141'),
'colourpicker rgb(240,100,141)' => build_test('rgb,240,100,141'),
'colour picker rgb(240,100,141)' => build_test('rgb,240,100,141'),
'rgb to hex rgb(240,100,141)' => build_test('rgb,240,100,141'),
'rgb to hex converter rgb(240,100,141)' => build_test('rgb,240,100,141'),
'rgb to hex rgb(240,100,141) converter' => build_test('rgb,240,100,141'),
'rgb to hsv rgb(240,100,141)' => build_test('rgb,240,100,141'),
'rgb to hsv converter rgb(240,100,141)' => build_test('rgb,240,100,141'),
'rgb to hsv rgb(240,100,141) converter' => build_test('rgb,240,100,141'),
'rgb to cmyk rgb(240,100,141)' => build_test('rgb,240,100,141'),
'rgb to cmyk converter rgb(240,100,141)' => build_test('rgb,240,100,141'),
'rgb to cmyk rgb(240,100,141) converter' => build_test('rgb,240,100,141'),
'rgb to hex color rgb(240,100,141)' => build_test('rgb,240,100,141'),
'rgb to hex colour rgb(240,100,141)' => build_test('rgb,240,100,141'),
'rgb to hsv color rgb(240,100,141)' => build_test('rgb,240,100,141'),
'rgb to hsv colour rgb(240,100,141)' => build_test('rgb,240,100,141'),
'rgb to cmyk color rgb(240,100,141)' => build_test('rgb,240,100,141'),
'rgb to cmyk colour rgb(240,100,141)' => build_test('rgb,240,100,141'),
'rgb to hex rgb(240,100,141) color' => build_test('rgb,240,100,141'),
'rgb to hex rgb(240,100,141) colour' => build_test('rgb,240,100,141'),
'rgb to hsv rgb(240,100,141) color' => build_test('rgb,240,100,141'),
'rgb to hsv rgb(240,100,141) colour' => build_test('rgb,240,100,141'),
'rgb to cmyk rgb(240,100,141) color' => build_test('rgb,240,100,141'),
'rgb to cmyk rgb(240,100,141) colour' => build_test('rgb,240,100,141'),
'rgb to hex conversion rgb(240,100,141)' => build_test('rgb,240,100,141'),
'rgb to hex rgb(240,100,141) conversion' => build_test('rgb,240,100,141'),
'rgb to hsv conversion rgb(240,100,141)' => build_test('rgb,240,100,141'),
'rgb to hsv rgb(240,100,141) conversion' => build_test('rgb,240,100,141'),
'rgb to cmyk conversion rgb(240,100,141)' => build_test('rgb,240,100,141'),
'rgb to cmyk rgb(240,100,141) conversion' => build_test('rgb,240,100,141'),
# Testing HSV
'colorpicker hsv(50,40,30)' => build_test('hsv,50,40,30'),
'color picker hsv(50,40,30)' => build_test('hsv,50,40,30'),
'colourpicker hsv(50,40,30)' => build_test('hsv,50,40,30'),
'colour picker hsv(50,40,30)' => build_test('hsv,50,40,30'),
'hsv to rgb hsv(50,40,30)' => build_test('hsv,50,40,30'),
'hsv to rgb converter hsv(50,40,30)' => build_test('hsv,50,40,30'),
'hsv to rgb hsv(50,40,30) converter' => build_test('hsv,50,40,30'),
'hsv to hex hsv(50,40,30)' => build_test('hsv,50,40,30'),
'hsv to hex converter hsv(50,40,30)' => build_test('hsv,50,40,30'),
'hsv to hex hsv(50,40,30) converter' => build_test('hsv,50,40,30'),
'hsv to cmyk hsv(50,40,30)' => build_test('hsv,50,40,30'),
'hsv to cmyk converter hsv(50,40,30)' => build_test('hsv,50,40,30'),
'hsv to cmyk hsv(50,40,30) converter' => build_test('hsv,50,40,30'),
'hsv to rgb color hsv(50,40,30)' => build_test('hsv,50,40,30'),
'hsv to rgb colour hsv(50,40,30)' => build_test('hsv,50,40,30'),
'hsv to hex color hsv(50,40,30)' => build_test('hsv,50,40,30'),
'hsv to hex colour hsv(50,40,30)' => build_test('hsv,50,40,30'),
'hsv to cmyk color hsv(50,40,30)' => build_test('hsv,50,40,30'),
'hsv to cmyk colour hsv(50,40,30)' => build_test('hsv,50,40,30'),
'hsv to rgb hsv(50,40,30) color' => build_test('hsv,50,40,30'),
'hsv to rgb hsv(50,40,30) colour' => build_test('hsv,50,40,30'),
'hsv to hex hsv(50,40,30) color' => build_test('hsv,50,40,30'),
'hsv to hex hsv(50,40,30) colour' => build_test('hsv,50,40,30'),
'hsv to cmyk hsv(50,40,30) color' => build_test('hsv,50,40,30'),
'hsv to cmyk hsv(50,40,30) colour' => build_test('hsv,50,40,30'),
'hsv to rgb conversion hsv(50,40,30)' => build_test('hsv,50,40,30'),
'hsv to rgb hsv(50,40,30) conversion' => build_test('hsv,50,40,30'),
'hsv to hex conversion hsv(50,40,30)' => build_test('hsv,50,40,30'),
'hsv to hex hsv(50,40,30) conversion' => build_test('hsv,50,40,30'),
'hsv to cmyk conversion hsv(50,40,30)' => build_test('hsv,50,40,30'),
'hsv to cmyk hsv(50,40,30) conversion' => build_test('hsv,50,40,30'),
# Testing CMYK
'colorpicker cmyk(50,40,30,20)' => build_test('cmyk,50,40,30,20'),
'color picker cmyk(50,40,30,20)' => build_test('cmyk,50,40,30,20'),
'colourpicker cmyk(50,40,30,20)' => build_test('cmyk,50,40,30,20'),
'colour picker cmyk(50,40,30,20)' => build_test('cmyk,50,40,30,20'),
'cmyk to rgb cmyk(50,40,30,20)' => build_test('cmyk,50,40,30,20'),
'cmyk to rgb converter cmyk(50,40,30,20)' => build_test('cmyk,50,40,30,20'),
'cmyk to rgb cmyk(50,40,30,20) converter' => build_test('cmyk,50,40,30,20'),
'cmyk to hex cmyk(50,40,30,20)' => build_test('cmyk,50,40,30,20'),
'cmyk to hex converter cmyk(50,40,30,20)' => build_test('cmyk,50,40,30,20'),
'cmyk to hex cmyk(50,40,30,20) converter' => build_test('cmyk,50,40,30,20'),
'cmyk to hsv cmyk(50,40,30,20)' => build_test('cmyk,50,40,30,20'),
'cmyk to hsv converter cmyk(50,40,30,20)' => build_test('cmyk,50,40,30,20'),
'cmyk to hsv cmyk(50,40,30,20) converter' => build_test('cmyk,50,40,30,20'),
'cmyk to rgb color cmyk(50,40,30,20)' => build_test('cmyk,50,40,30,20'),
'cmyk to rgb colour cmyk(50,40,30,20)' => build_test('cmyk,50,40,30,20'),
'cmyk to hex color cmyk(50,40,30,20)' => build_test('cmyk,50,40,30,20'),
'cmyk to hex colour cmyk(50,40,30,20)' => build_test('cmyk,50,40,30,20'),
'cmyk to hsv color cmyk(50,40,30,20)' => build_test('cmyk,50,40,30,20'),
'cmyk to hsv colour cmyk(50,40,30,20)' => build_test('cmyk,50,40,30,20'),
'cmyk to rgb cmyk(50,40,30,20) color' => build_test('cmyk,50,40,30,20'),
'cmyk to rgb cmyk(50,40,30,20) colour' => build_test('cmyk,50,40,30,20'),
'cmyk to hex cmyk(50,40,30,20) color' => build_test('cmyk,50,40,30,20'),
'cmyk to hex cmyk(50,40,30,20) colour' => build_test('cmyk,50,40,30,20'),
'cmyk to hsv cmyk(50,40,30,20) color' => build_test('cmyk,50,40,30,20'),
'cmyk to hsv cmyk(50,40,30,20) colour' => build_test('cmyk,50,40,30,20'),
'cmyk to rgb conversion cmyk(50,40,30,20)' => build_test('cmyk,50,40,30,20'),
'cmyk to rgb cmyk(50,40,30,20) conversion' => build_test('cmyk,50,40,30,20'),
'cmyk to hex conversion cmyk(50,40,30,20)' => build_test('cmyk,50,40,30,20'),
'cmyk to hex cmyk(50,40,30,20) conversion' => build_test('cmyk,50,40,30,20'),
'cmyk to hsv conversion cmyk(50,40,30,20)' => build_test('cmyk,50,40,30,20'),
'cmyk to hsv cmyk(50,40,30,20) conversion' => build_test('cmyk,50,40,30,20'),
# Queries to ignore.
'hello there colorpicker' => undef,
'hello there colourpicker' => undef,
'hello there colour picker' => undef,
'hello there color picker' => undef,
'testing color picker #e4e4e4' => undef,
'testing colour picker #e4e4e4' => undef,
'testing colourpicker #e4e4e4' => undef,
'testing colorpicker #e4e4e4' => undef,
'color picker download' => undef,
'colour picker download' => undef,
'color picker tutorial' => undef,
'colour picker tutorial' => undef
);
done_testing;