Skip to content

Commit e29b3ce

Browse files
committed
Tests: Add unit tests for Button block __experimentalLabel functionality (follows WordPress#74163)
1 parent e200f74 commit e29b3ce

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* Internal dependencies
3+
*/
4+
import { settings } from '..';
5+
6+
describe( 'Button block __experimentalLabel', () => {
7+
const { __experimentalLabel: getLabel } = settings;
8+
9+
it( 'returns custom name when metadata.name exists', () => {
10+
const attributes = {
11+
metadata: { name: 'My Custom Button' },
12+
text: 'Click me',
13+
};
14+
expect( getLabel( attributes ) ).toBe( 'My Custom Button' );
15+
} );
16+
17+
it( 'returns text when no custom name is set', () => {
18+
const attributes = {
19+
text: 'My Custom Button',
20+
};
21+
expect( getLabel( attributes ) ).toBe( 'My Custom Button' );
22+
} );
23+
24+
it( 'returns "Button" when text is empty', () => {
25+
const attributes = {
26+
text: '',
27+
};
28+
expect( getLabel( attributes ) ).toBe( 'Button' );
29+
} );
30+
31+
it( 'returns "Button" when text is undefined', () => {
32+
const attributes = {};
33+
expect( getLabel( attributes ) ).toBe( 'Button' );
34+
} );
35+
36+
it( 'returns "Button" when attributes is null', () => {
37+
expect( getLabel( null ) ).toBe( 'Button' );
38+
} );
39+
40+
it( 'returns "Button" when attributes is undefined', () => {
41+
expect( getLabel( undefined ) ).toBe( 'Button' );
42+
} );
43+
} );

0 commit comments

Comments
 (0)