Skip to content

Commit

Permalink
Add test coverage for nested objects
Browse files Browse the repository at this point in the history
  • Loading branch information
ockham committed Jun 4, 2024
1 parent 0439133 commit 3633a2b
Showing 1 changed file with 38 additions and 6 deletions.
44 changes: 38 additions & 6 deletions packages/blocks/src/store/test/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,43 +457,75 @@ describe( 'selectors', () => {
{
name: 'variation-1',
attributes: {
testAttribute: {
firstTestAttribute: {
nestedProperty: 1,
secondNestedProperty: 10,
},
secondTestAttribute: {
nestedProperty: {
firstDeeplyNestedProperty: 'a1',
secondDeeplyNestedProperty: 'a2',
},
},
},
isActive: [ 'testAttribute' ],
isActive: [
'firstTestAttribute',
'secondTestAttribute.nestedProperty',
],
},
{
name: 'variation-2',
attributes: {
testAttribute: {
firstTestAttribute: {
nestedProperty: 2,
secondNestedProperty: 20,
},
secondTestAttribute: {
nestedProperty: {
firstDeeplyNestedProperty: 'b1',
secondDeeplyNestedProperty: 'b2',
},
},
},
isActive: [ 'testAttribute' ],
isActive: [
'firstTestAttribute',
'secondTestAttribute.nestedProperty',
],
},
];
const state =
createBlockVariationsStateWithTestBlockType( variations );

expect(
getActiveBlockVariation( state, blockName, {
testAttribute: {
firstTestAttribute: {
nestedProperty: 1,
secondNestedProperty: 10,
otherNestedProperty: 5555,
},
secondTestAttribute: {
nestedProperty: {
firstDeeplyNestedProperty: 'a1',
secondDeeplyNestedProperty: 'a2',
otherDeeplyNestedProperty: 'ffff',
},
},
} )
).toEqual( variations[ 0 ] );
expect(
getActiveBlockVariation( state, blockName, {
testAttribute: {
firstTestAttribute: {
nestedProperty: 2,
secondNestedProperty: 20,
otherNestedProperty: 5555,
},
secondTestAttribute: {
nestedProperty: {
firstDeeplyNestedProperty: 'b1',
secondDeeplyNestedProperty: 'b2',
otherDeeplyNestedProperty: 'ffff',
},
},
} )
).toEqual( variations[ 1 ] );
} );
Expand Down

0 comments on commit 3633a2b

Please sign in to comment.