jekyll-swfobject 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,503 @@
1
+ require 'shoulda'
2
+ require 'mocha/setup'
3
+ require_relative './test_helper'
4
+
5
+ class TestSWFObjectTagConfig < Test::Unit::TestCase
6
+
7
+ include MockData
8
+ include Liquid
9
+
10
+ def setup
11
+ @test_data = getDefaultData().clone
12
+ end
13
+
14
+ def teardown
15
+ Jekyll.unstub(:configuration)
16
+ end
17
+
18
+ # tests of attributes defined _config.yml
19
+ # ---------------------------------------------
20
+
21
+ context 'template with attributes defined in Jekylls configuration (_config.yml)' do
22
+ should 'uses default values' do
23
+ expected = expected_output_by_test_data()
24
+ template = "{% swfobject #{@test_data[:swf_url]} %}{% endswfobject %}"
25
+ assert_template_result expected, template
26
+ end
27
+
28
+ should 'render a custom swf url' do
29
+ swf_url = 'another/path/to.swf'
30
+ @custom_config = {
31
+ :swf_url => swf_url
32
+ }
33
+ Jekyll.stubs(:configuration).returns({'swfobject' => @custom_config})
34
+ expected = expected_output_by_test_data(@custom_config)
35
+ template = "{% swfobject #{swf_url} %}{% endswfobject %}"
36
+ assert_template_result expected, template
37
+ end
38
+
39
+ should 'render a custom content_id' do
40
+ @custom_config = {
41
+ :content_id => 'any-content-id'
42
+ }
43
+ Jekyll.stubs(:configuration).returns({'swfobject' => @custom_config})
44
+ expected = expected_output_by_test_data(@custom_config)
45
+ template = "{% swfobject #{@test_data[:swf_url]} %}{% endswfobject %}"
46
+ assert_template_result expected, template
47
+ end
48
+
49
+ should 'render a custom width' do
50
+ @custom_config = {
51
+ :width => '23px'
52
+ }
53
+ Jekyll.stubs(:configuration).returns({'swfobject' => @custom_config})
54
+ expected = expected_output_by_test_data(@custom_config)
55
+ template = "{% swfobject #{@test_data[:swf_url]} %}{% endswfobject %}"
56
+ assert_template_result expected, template
57
+ end
58
+
59
+ should 'render a custom height' do
60
+ @custom_config = {
61
+ :height => '44px'
62
+ }
63
+ Jekyll.stubs(:configuration).returns({'swfobject' => @custom_config})
64
+ expected = expected_output_by_test_data(@custom_config)
65
+ template = "{% swfobject #{@test_data[:swf_url]} %}{% endswfobject %}"
66
+ assert_template_result expected, template
67
+ end
68
+
69
+ should 'render an alternative content' do
70
+ @custom_config = {
71
+ :alternative_content => '<p>An alternative content defined in _config.yml</p>'
72
+ }
73
+ Jekyll.stubs(:configuration).returns({'swfobject' => @custom_config})
74
+ expected = expected_output_by_test_data(@custom_config)
75
+ template = "{% swfobject #{@test_data[:swf_url]} %}{% endswfobject %}"
76
+ assert_template_result expected, template
77
+ end
78
+
79
+ should 'render a custom flash version' do
80
+ @custom_config = {
81
+ :version => '11.1'
82
+ }
83
+ Jekyll.stubs(:configuration).returns({'swfobject' => @custom_config})
84
+ expected = expected_output_by_test_data(@custom_config)
85
+ template = "{% swfobject #{@test_data[:swf_url]} %}{% endswfobject %}"
86
+ assert_template_result expected, template
87
+ end
88
+
89
+ should 'render a custom flashvar' do
90
+ varA = 'varA'
91
+ valueA = 'valueA'
92
+ flashvars = "var flashvars = {#{varA}:'#{valueA}'};"
93
+ @custom_config = {
94
+ :flashvars => flashvars
95
+ }
96
+ expected = expected_output_by_test_data(@custom_config)
97
+ Jekyll.stubs(:configuration).returns({
98
+ 'swfobject' => {
99
+ :flashvars => "#{varA}=#{valueA}"
100
+ }
101
+ })
102
+ template = "{% swfobject #{@test_data[:swf_url]} %}{% endswfobject %}"
103
+ assert_template_result expected, template
104
+ end
105
+
106
+ should 'render few custom flashvars' do
107
+ varA = 'varA'
108
+ valueA = 'valueA'
109
+ varB = 'varB'
110
+ valueB = 'valueB'
111
+ flashvars = "var flashvars = {#{varA}:'#{valueA}',#{varB}:'#{valueB}'};"
112
+ @custom_config = {
113
+ :flashvars => flashvars
114
+ }
115
+ expected = expected_output_by_test_data(@custom_config)
116
+ Jekyll.stubs(:configuration).returns({
117
+ 'swfobject' => {
118
+ :flashvars => "#{varA}=#{valueA}&#{varB}=#{valueB}"
119
+ }
120
+ })
121
+ template = "{% swfobject #{@test_data[:swf_url]} %}{% endswfobject %}"
122
+ assert_template_result expected, template
123
+ end
124
+
125
+ should 'render attribute id' do
126
+ attribute = 'id'
127
+ value = 'any-id'
128
+ attributes = "var attributes = {#{attribute}:'#{value}'};"
129
+ @custom_config = {
130
+ :attributes => attributes
131
+ }
132
+ Jekyll.stubs(:configuration).returns({
133
+ 'swfobject' => {
134
+ "#{attribute.to_sym}" => "#{value}",
135
+ }
136
+ })
137
+ expected = expected_output_by_test_data(@custom_config)
138
+ template = "{% swfobject #{@test_data[:swf_url]} %}{% endswfobject %}"
139
+ assert_template_result expected, template
140
+ end
141
+
142
+ should 'render attribute align' do
143
+ attribute = 'align'
144
+ value = 'l'
145
+ attributes = "var attributes = {#{attribute}:'#{value}'};"
146
+ @custom_config = {
147
+ :attributes => attributes
148
+ }
149
+ Jekyll.stubs(:configuration).returns({
150
+ 'swfobject' => {
151
+ "#{attribute.to_sym}" => "#{value}",
152
+ }
153
+ })
154
+ expected = expected_output_by_test_data(@custom_config)
155
+ template = "{% swfobject #{@test_data[:swf_url]} %}{% endswfobject %}"
156
+ assert_template_result expected, template
157
+ end
158
+
159
+ should 'render attribute name' do
160
+ attribute = 'name'
161
+ value = 'any-name'
162
+ attributes = "var attributes = {#{attribute}:'#{value}'};"
163
+ @custom_config = {
164
+ :attributes => attributes
165
+ }
166
+ Jekyll.stubs(:configuration).returns({
167
+ 'swfobject' => {
168
+ "#{attribute.to_sym}" => "#{value}",
169
+ }
170
+ })
171
+ expected = expected_output_by_test_data(@custom_config)
172
+ template = "{% swfobject #{@test_data[:swf_url]} %}{% endswfobject %}"
173
+ assert_template_result expected, template
174
+ end
175
+
176
+ should 'render attribute styleclass' do
177
+ attribute = 'styleclass'
178
+ value = 'any-class'
179
+ attributes = "var attributes = {#{attribute}:'#{value}'};"
180
+ @custom_config = {
181
+ :attributes => attributes
182
+ }
183
+ Jekyll.stubs(:configuration).returns({
184
+ 'swfobject' => {
185
+ "#{attribute.to_sym}" => "#{value}",
186
+ }
187
+ })
188
+ expected = expected_output_by_test_data(@custom_config)
189
+ template = "{% swfobject #{@test_data[:swf_url]} %}{% endswfobject %}"
190
+ assert_template_result expected, template
191
+ end
192
+
193
+ should 'render few custom attributes' do
194
+ attribute_id = 'id'
195
+ value_id = 'any-id'
196
+ attribute_align = 'align'
197
+ value_align = 'center'
198
+ attributes = "var attributes = {#{attribute_id}:'#{value_id}',#{attribute_align}:'#{value_align}'};"
199
+ @custom_config = {
200
+ :attributes => attributes
201
+ }
202
+ Jekyll.stubs(:configuration).returns({
203
+ 'swfobject' => {
204
+ "#{attribute_id.to_sym}" => "#{value_id}",
205
+ "#{attribute_align.to_sym}" => "#{value_align}"
206
+ }
207
+ })
208
+ expected = expected_output_by_test_data(@custom_config)
209
+ template = "{% swfobject #{@test_data[:swf_url]} %}{% endswfobject %}"
210
+ assert_template_result expected, template
211
+ end
212
+
213
+ should 'render param play' do
214
+ param = 'play'
215
+ value = 'true'
216
+ rendered_params = "var params = {#{param}:'#{value}'};"
217
+ @custom_config = {
218
+ :params => rendered_params
219
+ }
220
+ Jekyll.stubs(:configuration).returns({
221
+ 'swfobject' => {
222
+ "#{param.to_sym}" => "#{value}"
223
+ }
224
+ })
225
+ expected = expected_output_by_test_data(@custom_config)
226
+ template = "{% swfobject #{@test_data[:swf_url]} %}{% endswfobject %}"
227
+ assert_template_result expected, template
228
+ end
229
+
230
+ should 'render param loop' do
231
+ param = 'loop'
232
+ value = 'false'
233
+ rendered_params = "var params = {#{param}:'#{value}'};"
234
+ @custom_config = {
235
+ :params => rendered_params
236
+ }
237
+ Jekyll.stubs(:configuration).returns({
238
+ 'swfobject' => {
239
+ "#{param.to_sym}" => "#{value}"
240
+ }
241
+ })
242
+ expected = expected_output_by_test_data(@custom_config)
243
+ template = "{% swfobject #{@test_data[:swf_url]} %}{% endswfobject %}"
244
+ assert_template_result expected, template
245
+ end
246
+
247
+ should 'render param menu' do
248
+ param = 'menu'
249
+ value = 'false'
250
+ rendered_params = "var params = {#{param}:'#{value}'};"
251
+ @custom_config = {
252
+ :params => rendered_params
253
+ }
254
+ Jekyll.stubs(:configuration).returns({
255
+ 'swfobject' => {
256
+ "#{param.to_sym}" => "#{value}"
257
+ }
258
+ })
259
+ expected = expected_output_by_test_data(@custom_config)
260
+ template = "{% swfobject #{@test_data[:swf_url]} %}{% endswfobject %}"
261
+ assert_template_result expected, template
262
+ end
263
+
264
+ should 'render param quality' do
265
+ param = 'quality'
266
+ value = 'best'
267
+ rendered_params = "var params = {#{param}:'#{value}'};"
268
+ @custom_config = {
269
+ :params => rendered_params
270
+ }
271
+ Jekyll.stubs(:configuration).returns({
272
+ 'swfobject' => {
273
+ "#{param.to_sym}" => "#{value}"
274
+ }
275
+ })
276
+ expected = expected_output_by_test_data(@custom_config)
277
+ template = "{% swfobject #{@test_data[:swf_url]} %}{% endswfobject %}"
278
+ assert_template_result expected, template
279
+ end
280
+
281
+ should 'render param scale' do
282
+ param = 'scale'
283
+ value = 'exactfit'
284
+ rendered_params = "var params = {#{param}:'#{value}'};"
285
+ @custom_config = {
286
+ :params => rendered_params
287
+ }
288
+ Jekyll.stubs(:configuration).returns({
289
+ 'swfobject' => {
290
+ "#{param.to_sym}" => "#{value}"
291
+ }
292
+ })
293
+ expected = expected_output_by_test_data(@custom_config)
294
+ template = "{% swfobject #{@test_data[:swf_url]} %}{% endswfobject %}"
295
+ assert_template_result expected, template
296
+ end
297
+
298
+ should 'render param salign' do
299
+ param = 'salign'
300
+ value = 'tr'
301
+ rendered_params = "var params = {#{param}:'#{value}'};"
302
+ @custom_config = {
303
+ :params => rendered_params
304
+ }
305
+ Jekyll.stubs(:configuration).returns({
306
+ 'swfobject' => {
307
+ "#{param.to_sym}" => "#{value}"
308
+ }
309
+ })
310
+ expected = expected_output_by_test_data(@custom_config)
311
+ template = "{% swfobject #{@test_data[:swf_url]} %}{% endswfobject %}"
312
+ assert_template_result expected, template
313
+ end
314
+
315
+ should 'render param wmode' do
316
+ param = 'wmode'
317
+ value = 'window'
318
+ rendered_params = "var params = {#{param}:'#{value}'};"
319
+ @custom_config = {
320
+ :params => rendered_params
321
+ }
322
+ Jekyll.stubs(:configuration).returns({
323
+ 'swfobject' => {
324
+ "#{param.to_sym}" => "#{value}"
325
+ }
326
+ })
327
+ expected = expected_output_by_test_data(@custom_config)
328
+ template = "{% swfobject #{@test_data[:swf_url]} %}{% endswfobject %}"
329
+ assert_template_result expected, template
330
+ end
331
+
332
+ should 'render param bgcolor' do
333
+ param = 'bgcolor'
334
+ value = '#FFF'
335
+ rendered_params = "var params = {#{param}:'#{value}'};"
336
+ @custom_config = {
337
+ :params => rendered_params
338
+ }
339
+ Jekyll.stubs(:configuration).returns({
340
+ 'swfobject' => {
341
+ "#{param.to_sym}" => "#{value}"
342
+ }
343
+ })
344
+ expected = expected_output_by_test_data(@custom_config)
345
+ template = "{% swfobject #{@test_data[:swf_url]} %}{% endswfobject %}"
346
+ assert_template_result expected, template
347
+ end
348
+
349
+ should 'render param base' do
350
+ param = 'base'
351
+ value = 'http://any-base-url.com'
352
+ rendered_params = "var params = {#{param}:'#{value}'};"
353
+ @custom_config = {
354
+ :params => rendered_params
355
+ }
356
+ Jekyll.stubs(:configuration).returns({
357
+ 'swfobject' => {
358
+ "#{param.to_sym}" => "#{value}"
359
+ }
360
+ })
361
+ expected = expected_output_by_test_data(@custom_config)
362
+ template = "{% swfobject #{@test_data[:swf_url]} %}{% endswfobject %}"
363
+ assert_template_result expected, template
364
+ end
365
+
366
+ should 'render param swliveconnect' do
367
+ param = 'swliveconnect'
368
+ value = 'true'
369
+ rendered_params = "var params = {#{param}:'#{value}'};"
370
+ @custom_config = {
371
+ :params => rendered_params
372
+ }
373
+ Jekyll.stubs(:configuration).returns({
374
+ 'swfobject' => {
375
+ "#{param.to_sym}" => "#{value}"
376
+ }
377
+ })
378
+ expected = expected_output_by_test_data(@custom_config)
379
+ template = "{% swfobject #{@test_data[:swf_url]} %}{% endswfobject %}"
380
+ assert_template_result expected, template
381
+ end
382
+
383
+ should 'render param devicefont' do
384
+ param = 'devicefont'
385
+ value = 'false'
386
+ rendered_params = "var params = {#{param}:'#{value}'};"
387
+ @custom_config = {
388
+ :params => rendered_params
389
+ }
390
+ Jekyll.stubs(:configuration).returns({
391
+ 'swfobject' => {
392
+ "#{param.to_sym}" => "#{value}"
393
+ }
394
+ })
395
+ expected = expected_output_by_test_data(@custom_config)
396
+ template = "{% swfobject #{@test_data[:swf_url]} %}{% endswfobject %}"
397
+ assert_template_result expected, template
398
+ end
399
+
400
+ should 'render param allowscriptaccess' do
401
+ param = 'allowscriptaccess'
402
+ value = 'sameDomain'
403
+ rendered_params = "var params = {#{param}:'#{value}'};"
404
+ @custom_config = {
405
+ :params => rendered_params
406
+ }
407
+ Jekyll.stubs(:configuration).returns({
408
+ 'swfobject' => {
409
+ "#{param.to_sym}" => "#{value}"
410
+ }
411
+ })
412
+ expected = expected_output_by_test_data(@custom_config)
413
+ template = "{% swfobject #{@test_data[:swf_url]} %}{% endswfobject %}"
414
+ assert_template_result expected, template
415
+ end
416
+
417
+ should 'render param seamlesstabbing' do
418
+ param = 'seamlesstabbing'
419
+ value = 'false'
420
+ rendered_params = "var params = {#{param}:'#{value}'};"
421
+ @custom_config = {
422
+ :params => rendered_params
423
+ }
424
+ Jekyll.stubs(:configuration).returns({
425
+ 'swfobject' => {
426
+ "#{param.to_sym}" => "#{value}"
427
+ }
428
+ })
429
+ expected = expected_output_by_test_data(@custom_config)
430
+ template = "{% swfobject #{@test_data[:swf_url]} %}{% endswfobject %}"
431
+ assert_template_result expected, template
432
+ end
433
+
434
+ should 'render param allowfullscreen' do
435
+ param = 'allowfullscreen'
436
+ value = 'true'
437
+ rendered_params = "var params = {#{param}:'#{value}'};"
438
+ @custom_config = {
439
+ :params => rendered_params
440
+ }
441
+ Jekyll.stubs(:configuration).returns({
442
+ 'swfobject' => {
443
+ "#{param.to_sym}" => "#{value}"
444
+ }
445
+ })
446
+ expected = expected_output_by_test_data(@custom_config)
447
+ template = "{% swfobject #{@test_data[:swf_url]} %}{% endswfobject %}"
448
+ assert_template_result expected, template
449
+ end
450
+
451
+ should 'render param allownetworking' do
452
+ param = 'allownetworking'
453
+ value = 'none'
454
+ rendered_params = "var params = {#{param}:'#{value}'};"
455
+ @custom_config = {
456
+ :params => rendered_params
457
+ }
458
+ Jekyll.stubs(:configuration).returns({
459
+ 'swfobject' => {
460
+ "#{param.to_sym}" => "#{value}"
461
+ }
462
+ })
463
+ expected = expected_output_by_test_data(@custom_config)
464
+ template = "{% swfobject #{@test_data[:swf_url]} %}{% endswfobject %}"
465
+ assert_template_result expected, template
466
+ end
467
+
468
+ should 'render few custom params' do
469
+ attributeA = 'allowfullscreen'
470
+ valueA = 'true'
471
+ attributeB = 'allownetworking'
472
+ valueB = 'false'
473
+ rendered_params = "var params = {#{attributeA}:'#{valueA}',#{attributeB}:'#{valueB}'};"
474
+ @custom_config = {
475
+ :params => rendered_params
476
+ }
477
+ Jekyll.stubs(:configuration).returns({
478
+ 'swfobject' => {
479
+ "#{attributeA.to_sym}" => "#{valueA}",
480
+ "#{attributeB.to_sym}" => "#{valueB}"
481
+ }
482
+ })
483
+ expected = expected_output_by_test_data(@custom_config)
484
+ template = "{% swfobject #{@test_data[:swf_url]} %}{% endswfobject %}"
485
+ assert_template_result expected, template
486
+ end
487
+
488
+ should 'NOT render a value, which are not supported' do
489
+ attribute = 'halligalli'
490
+ value = 'true'
491
+ Jekyll.stubs(:configuration).returns({
492
+ 'swfobject' => {
493
+ "#{attribute.to_sym}" => "#{value}"
494
+ }
495
+ })
496
+ template = "{% swfobject #{@test_data[:swf_url]} %}{% endswfobject %}"
497
+ rendered = Template.parse(template).render({})
498
+ assert(!rendered.include?(attribute))
499
+ end
500
+
501
+ end
502
+
503
+ end