|
538 | 538 | end |
539 | 539 | end |
540 | 540 |
|
| 541 | +test ":srcset on img with an Array" do |
| 542 | + output = phlex { img(srcset: []) } |
| 543 | + assert_equal_html output, %(<img srcset="">) |
| 544 | + |
| 545 | + output = phlex { img(srcset: ["image.jpg 1x", "[email protected] 2x"]) } |
| 546 | + assert_equal_html output, %(<img srcset="image.jpg 1x, [email protected] 2x">) |
| 547 | +end |
| 548 | + |
| 549 | +test ":media on link with an Array" do |
| 550 | + output = phlex { link(media: []) } |
| 551 | + assert_equal_html output, %(<link media="">) |
| 552 | + |
| 553 | + output = phlex { link(media: ["screen", "print"]) } |
| 554 | + assert_equal_html output, %(<link media="screen, print">) |
| 555 | + |
| 556 | + output = phlex { link(media: ["(max-width: 600px)", "(min-width: 1200px)"]) } |
| 557 | + assert_equal_html output, %(<link media="(max-width: 600px), (min-width: 1200px)">) |
| 558 | +end |
| 559 | + |
| 560 | +test ":sizes on link with an Array" do |
| 561 | + output = phlex { link(sizes: []) } |
| 562 | + assert_equal_html output, %(<link sizes="">) |
| 563 | + |
| 564 | + output = phlex { link(sizes: ["16x16", "32x32", "64x64"]) } |
| 565 | + assert_equal_html output, %(<link sizes="16x16, 32x32, 64x64">) |
| 566 | +end |
| 567 | + |
| 568 | +test ":imagesrcset on link with an Array when rel is preload and as is image" do |
| 569 | + output = phlex { link(imagesrcset: [], rel: "preload", as: "image") } |
| 570 | + assert_equal_html output, %(<link imagesrcset="" rel="preload" as="image">) |
| 571 | + |
| 572 | + output = phlex { link(imagesrcset: ["image.jpg 1x", "[email protected] 2x"], rel: "preload", as: "image") } |
| 573 | + assert_equal_html output, %(<link imagesrcset="image.jpg 1x, [email protected] 2x" rel="preload" as="image">) |
| 574 | + |
| 575 | + output = phlex { link(imagesrcset: ["image.jpg 1x", "[email protected] 2x"], rel: :preload, as: :image) } |
| 576 | + assert_equal_html output, %(<link imagesrcset="image.jpg 1x, [email protected] 2x" rel="preload" as="image">) |
| 577 | + |
| 578 | + output = phlex { link(:imagesrcset => ["image.jpg 1x", "[email protected] 2x"], "rel" => "preload", "as" => "image") } |
| 579 | + assert_equal_html output, %(<link imagesrcset="image.jpg 1x, [email protected] 2x" rel="preload" as="image">) |
| 580 | +end |
| 581 | + |
| 582 | +test ":accept on input with array when type is file" do |
| 583 | + output = phlex { input(accept: [], type: "file") } |
| 584 | + assert_equal_html output, %(<input accept="" type="file">) |
| 585 | + |
| 586 | + output = phlex { input(accept: ["image/jpeg", "image/png"], type: "file") } |
| 587 | + assert_equal_html output, %(<input accept="image/jpeg, image/png" type="file">) |
| 588 | + |
| 589 | + output = phlex { input(accept: ["image/jpeg", "image/png"], type: :file) } |
| 590 | + assert_equal_html output, %(<input accept="image/jpeg, image/png" type="file">) |
| 591 | + |
| 592 | + output = phlex { input(:accept => ["image/jpeg", "image/png"], "type" => "file") } |
| 593 | + assert_equal_html output, %(<input accept="image/jpeg, image/png" type="file">) |
| 594 | +end |
| 595 | + |
541 | 596 | # This is just for coverage. |
542 | 597 | Phlex::HTML.call do |c| |
543 | 598 | c.__send__(:__styles__, nil) |
|
0 commit comments