-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathIterableEmbeddedMessageElementsButtonAction.test.ts
More file actions
40 lines (33 loc) · 1.57 KB
/
Copy pathIterableEmbeddedMessageElementsButtonAction.test.ts
File metadata and controls
40 lines (33 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { IterableEmbeddedMessageElementsButtonAction } from '../embedded/classes/IterableEmbeddedMessageElementsButtonAction';
import { Iterable } from '../core/classes/Iterable';
describe('IterableEmbeddedMessageDefaultAction', () => {
it('should create an instance with the correct properties', () => {
Iterable.logger.log(
'iterableEmbeddedMessageElementsButtonAction_fromDict_valid_dictionary'
);
const dict = { type: 'openUrl', data: 'https://example.com' };
const action = IterableEmbeddedMessageElementsButtonAction.fromDict(dict);
expect(action).toBeInstanceOf(IterableEmbeddedMessageElementsButtonAction);
expect(action.type).toBe('openUrl');
expect(action.data).toBe('https://example.com');
});
it('should create an instance from a dictionary with data omitted', () => {
Iterable.logger.log(
'iterableEmbeddedMessageElementsButtonAction_fromDict_valid_dictionary_with_data_omitted'
);
const dict = { type: 'action://join', data: '' };
const action = IterableEmbeddedMessageElementsButtonAction.fromDict(dict);
expect(action).toBeInstanceOf(IterableEmbeddedMessageElementsButtonAction);
expect(action.type).toBe('action://join');
expect(action.data).toBe('');
});
it('should throw an error if type is missing in fromDict', () => {
Iterable.logger.log(
'iterableEmbeddedMessageElementsButtonAction_fromDict_invalid_dictionary_missing_type'
);
const dict = { data: 'foo' };
expect(() =>
IterableEmbeddedMessageElementsButtonAction.fromDict(dict)
).toThrow('type is required');
});
});