11import { IterableEmbeddedMessageElementsButton } from '../embedded/classes/IterableEmbeddedMessageElementsButton' ;
2- import { IterableEmbeddedMessageElementsButtonAction } from '../embedded/classes/IterableEmbeddedMessageElementsButtonAction' ;
32import { Iterable } from '../core/classes/Iterable' ;
43
54describe ( 'IterableEmbeddedMessageButton' , ( ) => {
@@ -14,14 +13,12 @@ describe('IterableEmbeddedMessageButton', () => {
1413 action : { type : 'openUrl' , data : 'https://example.com' } ,
1514 } ;
1615
17- const button = IterableEmbeddedMessageElementsButton . fromDict ( dict ) ;
16+ const button = new IterableEmbeddedMessageElementsButton ( dict ) ;
1817
1918 expect ( button ) . toBeInstanceOf ( IterableEmbeddedMessageElementsButton ) ;
2019 expect ( button . id ) . toBe ( 'button-123' ) ;
2120 expect ( button . title ) . toBe ( 'Click Me!' ) ;
22- expect ( button . action ) . toBeInstanceOf (
23- IterableEmbeddedMessageElementsButtonAction
24- ) ;
21+ expect ( button . action ) . toBeInstanceOf ( Object ) ;
2522 expect ( button . action ?. type ) . toBe ( 'openUrl' ) ;
2623 expect ( button . action ?. data ) . toBe ( 'https://example.com' ) ;
2724 } ) ;
@@ -31,7 +28,7 @@ describe('IterableEmbeddedMessageButton', () => {
3128
3229 const dict = { id : 'button-123' } ;
3330
34- const button = IterableEmbeddedMessageElementsButton . fromDict ( dict ) ;
31+ const button = new IterableEmbeddedMessageElementsButton ( dict ) ;
3532
3633 expect ( button ) . toBeInstanceOf ( IterableEmbeddedMessageElementsButton ) ;
3734 expect ( button . id ) . toBe ( 'button-123' ) ;
@@ -47,23 +44,23 @@ describe('IterableEmbeddedMessageButton', () => {
4744 title : 'Click Me!' ,
4845 } ;
4946
50- const button = IterableEmbeddedMessageElementsButton . fromDict ( dict ) ;
47+ const button = new IterableEmbeddedMessageElementsButton ( dict ) ;
5148
5249 expect ( button ) . toBeInstanceOf ( IterableEmbeddedMessageElementsButton ) ;
5350 expect ( button . id ) . toBe ( 'button-123' ) ;
5451 expect ( button . title ) . toBe ( 'Click Me!' ) ;
5552 expect ( button . action ) . toBeUndefined ( ) ;
5653 } ) ;
5754
58- it ( 'should throw an error if id is missing in fromDict ' , ( ) => {
55+ it ( 'should throw an error if id is missing' , ( ) => {
5956 Iterable . logger . log ( 'iterableEmbeddedMessageButton_fromDict_missing_id' ) ;
6057
6158 const dict = {
6259 title : 'Click Me!' ,
6360 action : { type : 'openUrl' , data : 'https://example.com' } ,
6461 } ;
65-
66- expect ( ( ) => IterableEmbeddedMessageElementsButton . fromDict ( dict ) ) . toThrow (
62+ // @ts -expect-error - id is purposely missing
63+ expect ( ( ) => new IterableEmbeddedMessageElementsButton ( dict ) ) . toThrow (
6764 'id is required'
6865 ) ;
6966 } ) ;
@@ -78,13 +75,11 @@ describe('IterableEmbeddedMessageButton', () => {
7875 action : { type : 'close' } ,
7976 } ;
8077
81- const button = IterableEmbeddedMessageElementsButton . fromDict ( dict ) ;
78+ const button = new IterableEmbeddedMessageElementsButton ( dict ) ;
8279
8380 expect ( button ) . toBeInstanceOf ( IterableEmbeddedMessageElementsButton ) ;
8481 expect ( button . id ) . toBe ( 'button-123' ) ;
85- expect ( button . action ) . toBeInstanceOf (
86- IterableEmbeddedMessageElementsButtonAction
87- ) ;
82+ expect ( button . action ) . toBeInstanceOf ( Object ) ;
8883 expect ( button . action ?. type ) . toBe ( 'close' ) ;
8984 expect ( button . action ?. data ) . toBeUndefined ( ) ;
9085 } ) ;
0 commit comments