|
1 |
| -import { ComponentType } from 'discord-api-types/v10'; |
| 1 | +import { ButtonStyle, ComponentType } from 'discord-api-types/v10'; |
2 | 2 | import { describe, expect, test } from 'vitest';
|
3 | 3 | import { PrimaryButtonBuilder } from '../../../src/components/button/CustomIdButton';
|
4 | 4 | import { SectionBuilder } from '../../../src/components/v2/Section';
|
@@ -123,6 +123,28 @@ describe('Section', () => {
|
123 | 123 | });
|
124 | 124 | });
|
125 | 125 |
|
| 126 | + test('GIVEN section with primary button accessory JSON THEN returns valid toJSON data', () => { |
| 127 | + const section = new SectionBuilder() |
| 128 | + .addTextDisplayComponents(new TextDisplayBuilder().setContent('Hello world')) |
| 129 | + .setPrimaryButtonAccessory({ |
| 130 | + type: ComponentType.Button as const, |
| 131 | + style: ButtonStyle.Primary as const, |
| 132 | + custom_id: 'click_me', |
| 133 | + lLabel: 'Click me', |
| 134 | + }); |
| 135 | + |
| 136 | + expect(section.toJSON()).toEqual({ |
| 137 | + type: ComponentType.Section, |
| 138 | + components: [{ type: ComponentType.TextDisplay, content: 'Hello world' }], |
| 139 | + accessory: { |
| 140 | + type: ComponentType.Button, |
| 141 | + style: 1, |
| 142 | + custom_id: 'click_me', |
| 143 | + label: 'Click me', |
| 144 | + }, |
| 145 | + }); |
| 146 | + }); |
| 147 | + |
126 | 148 | test('GIVEN changing accessory type THEN returns the latest accessory in toJSON', () => {
|
127 | 149 | const section = new SectionBuilder()
|
128 | 150 | .addTextDisplayComponents(new TextDisplayBuilder().setContent('Hello world'))
|
|
0 commit comments