refactor: make public builder props getters (#7422)

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: Antonio Román <kyradiscord@gmail.com>
This commit is contained in:
Suneet Tipirneni
2022-02-13 07:06:11 -05:00
committed by GitHub
parent 3ae6f3c313
commit e8252ed3b9
17 changed files with 370 additions and 233 deletions

View File

@@ -5,7 +5,7 @@ describe('Action Row Components', () => {
describe('Assertion Tests', () => {
test('GIVEN valid components THEN do not throw', () => {
expect(() => new ActionRow().addComponents(new ButtonComponent())).not.toThrowError();
expect(() => new ActionRow().setComponents(new ButtonComponent())).not.toThrowError();
expect(() => new ActionRow().setComponents([new ButtonComponent()])).not.toThrowError();
});
test('GIVEN valid JSON input THEN valid JSON output is given', () => {
@@ -84,10 +84,10 @@ describe('Action Row Components', () => {
.setCustomId('1234')
.setMaxValues(10)
.setMinValues(12)
.setOptions(
.setOptions([
new SelectMenuOption().setLabel('one').setValue('one'),
new SelectMenuOption().setLabel('two').setValue('two'),
);
]);
expect(new ActionRow().addComponents(button).toJSON()).toEqual(rowWithButtonData);
expect(new ActionRow().addComponents(selectMenu).toJSON()).toEqual(rowWithSelectMenuData);

View File

@@ -23,7 +23,7 @@ describe('Button Components', () => {
.setEmoji({ name: 'test' })
.setDescription('description');
expect(() => selectMenu().addOptions(option)).not.toThrowError();
expect(() => selectMenu().setOptions(option)).not.toThrowError();
expect(() => selectMenu().setOptions([option])).not.toThrowError();
});
test('GIVEN invalid inputs THEN Select Menu does throw', () => {
@@ -55,17 +55,25 @@ describe('Button Components', () => {
description: 'test',
};
const selectMenuData: APISelectMenuComponent = {
const selectMenuDataWithoutOptions = {
type: ComponentType.SelectMenu,
custom_id: 'test',
max_values: 10,
min_values: 3,
disabled: true,
options: [selectMenuOptionData],
placeholder: 'test',
} as const;
const selectMenuData: APISelectMenuComponent = {
...selectMenuDataWithoutOptions,
options: [selectMenuOptionData],
};
expect(new SelectMenuComponent(selectMenuData).toJSON()).toEqual(selectMenuData);
expect(
new SelectMenuComponent(selectMenuDataWithoutOptions)
.addOptions(new SelectMenuOption(selectMenuOptionData))
.toJSON(),
).toEqual(selectMenuData);
expect(new SelectMenuOption(selectMenuOptionData).toJSON()).toEqual(selectMenuOptionData);
});
});