@@ -662,3 +662,63 @@ describe('ObjectSchema - recordName', () => {
662662 expect ( result . recordName ) . toBeUndefined ( ) ;
663663 } ) ;
664664} ) ;
665+
666+ describe ( 'ObjectSchema.create()' , ( ) => {
667+ it ( 'should auto-generate label from snake_case name' , ( ) => {
668+ const result = ObjectSchema . create ( {
669+ name : 'project_task' ,
670+ fields : {
671+ title : { type : 'text' } ,
672+ } ,
673+ } ) ;
674+ expect ( result . label ) . toBe ( 'Project Task' ) ;
675+ } ) ;
676+
677+ it ( 'should preserve explicitly provided label' , ( ) => {
678+ const result = ObjectSchema . create ( {
679+ name : 'project_task' ,
680+ label : 'My Custom Label' ,
681+ fields : {
682+ title : { type : 'text' } ,
683+ } ,
684+ } ) ;
685+ expect ( result . label ) . toBe ( 'My Custom Label' ) ;
686+ } ) ;
687+
688+ it ( 'should auto-generate label from single-word name' , ( ) => {
689+ const result = ObjectSchema . create ( {
690+ name : 'account' ,
691+ fields : {
692+ name : { type : 'text' } ,
693+ } ,
694+ } ) ;
695+ expect ( result . label ) . toBe ( 'Account' ) ;
696+ } ) ;
697+
698+ it ( 'should validate and apply defaults' , ( ) => {
699+ const result = ObjectSchema . create ( {
700+ name : 'task' ,
701+ fields : {
702+ title : { type : 'text' } ,
703+ } ,
704+ } ) ;
705+ expect ( result . active ) . toBe ( true ) ;
706+ expect ( result . isSystem ) . toBe ( false ) ;
707+ expect ( result . abstract ) . toBe ( false ) ;
708+ expect ( result . datasource ) . toBe ( 'default' ) ;
709+ } ) ;
710+
711+ it ( 'should throw on invalid name format' , ( ) => {
712+ expect ( ( ) => ObjectSchema . create ( {
713+ name : 'InvalidName' ,
714+ fields : { title : { type : 'text' } } ,
715+ } ) ) . toThrow ( ) ;
716+ } ) ;
717+
718+ it ( 'should throw on invalid field name format' , ( ) => {
719+ expect ( ( ) => ObjectSchema . create ( {
720+ name : 'task' ,
721+ fields : { InvalidField : { type : 'text' } } ,
722+ } ) ) . toThrow ( ) ;
723+ } ) ;
724+ } ) ;
0 commit comments