Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oakesjosh committed Dec 20, 2024
1 parent d977569 commit a3e5a62
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion includes/blocks/class-kadence-blocks-table-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function build_css( $attributes, $css, $unique_id, $unique_style_id ) {
if( !empty( $attributes['columnBackgrounds'] ) ) {
foreach( $attributes['columnBackgrounds'] as $index => $background ) {
if ( $background ) {
if( $attributes['isFirstColumnHeader'] ) {
if (!empty($attributes['isFirstColumnHeader']) && $attributes['isFirstColumnHeader']) {
$css->set_selector( '.kb-table-container .kb-table' . esc_attr( $unique_id ) . ' td:nth-of-type(' . ( $index ) . ')' );
} else {
$css->set_selector( '.kb-table-container .kb-table' . esc_attr( $unique_id ) . ' td:nth-of-type(' . ( $index + 1 ) . ')' );
Expand Down
3 changes: 2 additions & 1 deletion tests/_support/Classes/KadenceBlocksUnit.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ public function testBlockIsRegistered()
public function testCustomAchorRendered()
{
// Exclude non-dynamic blocks.
$exclude = ['testimonial', 'testimonials', 'tabs', 'spacer', 'rowlayout', 'image', 'forum', 'countdown', 'column', 'advancedgallery', 'advancedbtn', 'accordion'];
$exclude = ['testimonial', 'testimonials', 'tabs', 'spacer', 'rowlayout', 'image', 'form', 'countdown', 'column', 'advancedgallery', 'advancedbtn', 'navigation-link', 'singlebtn', 'accordion'];

if (!empty($this->block_name) && !in_array($this->block_name, $exclude) && $this->tester->block_supports_anchor('kadence/' . $this->block_name) ) {
$uniqueID = '123_abcd';
$attrs = ['anchor' => 'my-custom-anchor-123', 'uniqueID' => $uniqueID];
$attrs = $this->block->get_attributes_with_defaults( $uniqueID, $attrs );

$block_instance = $this->generate_block_instance('kadence/' . $this->block_name, $attrs);

Expand Down
7 changes: 3 additions & 4 deletions tests/wpunit/Blocks/TableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,12 @@ public function testColumndBackgroundCss() {
$css_output = $this->block->build_css($attributes, $this->css, $unique_id, $unique_id);
$css_helper = new CSSTestHelper($css_output);


$this->assertStringNotContainsString( 'td:nth-of-type(1)', $css_output );
$this->assertStringNotContainsString( 'td:nth-of-type(4)', $css_output );

$this->assertTrue(
$css_helper->assertCSSPropertiesEqual(
'.kb-table-container .kb-table'.$unique_id.' td:nth-of-type(2), .kb-table-container .kb-table'.$unique_id.' th:nth-of-type(2)',
'.kb-table-container .kb-table'.$unique_id.' td:nth-of-type(2)',
[
'background-color' => '#fff'
]
Expand All @@ -157,7 +156,7 @@ public function testColumndBackgroundCss() {

$this->assertTrue(
$css_helper->assertCSSPropertiesEqual(
'.kb-table-container .kb-table'.$unique_id.' td:nth-of-type(3), .kb-table-container .kb-table'.$unique_id.' th:nth-of-type(3)',
'.kb-table-container .kb-table'.$unique_id.' td:nth-of-type(3)',
[
'background-color' => '#444'
]
Expand All @@ -166,7 +165,7 @@ public function testColumndBackgroundCss() {

$this->assertTrue(
$css_helper->assertCSSPropertiesEqual(
'.kb-table-container .kb-table'.$unique_id.' td:nth-of-type(5), .kb-table-container .kb-table'.$unique_id.' th:nth-of-type(5)',
'.kb-table-container .kb-table'.$unique_id.' td:nth-of-type(5)',
[
'background-color' => 'red'
]
Expand Down

0 comments on commit a3e5a62

Please sign in to comment.