Skip to content

Commit

Permalink
Add a test for dark color scheme and SVG
Browse files Browse the repository at this point in the history
  • Loading branch information
gchtr committed Apr 6, 2023
1 parent e6107da commit 7aa0659
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/test-color-scheme-dark.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,23 @@ public function test_picture_webp_with_lazy_attributes() {

$this->assertEquals( $expected, $result );
}

public function test_svg() {
$attachment = $this->create_image( [ 'file' => 'sveegee.svg' ] );
$attachment_dark = $this->create_image( [
'file' => 'svg-400-200.svg',
] );

$image = Timmy::get_image( $attachment->ID, 'large' );
$image->set_color_scheme_dark_image( $attachment_dark->ID );

$result = $image->picture_responsive();
$expected = sprintf(
'<source srcset="%1$s/svg-400-200.svg" media="(prefers-color-scheme: dark)">%2$s<img src="%1$s/sveegee.svg" width="1400" height="1400" alt="" loading="lazy">',
$this->get_upload_url(),
PHP_EOL
);

$this->assertEquals( $expected, $result );
}
}

0 comments on commit 7aa0659

Please sign in to comment.