File tree Expand file tree Collapse file tree
packages/block-library/src/button/test Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ } ) ;
You can’t perform that action at this time.
0 commit comments