refactor: use arrays instead of rest parameters for builders (#7759)

This commit is contained in:
Suneet Tipirneni
2022-04-21 12:56:10 -04:00
committed by GitHub
parent f22245e9d0
commit 29293d7bbb
11 changed files with 66 additions and 69 deletions

View File

@@ -48,15 +48,11 @@ describe('Modals', () => {
test('GIVEN valid fields THEN builder does not throw', () => {
expect(() =>
modal().setTitle('test').setCustomId('foobar').setComponents(new ActionRowBuilder()),
modal().setTitle('test').setCustomId('foobar').setComponents([new ActionRowBuilder()]),
).not.toThrowError();
});
test('GIVEN invalid fields THEN builder does throw', () => {
expect(() =>
// @ts-expect-error
modal().setTitle('test').setCustomId('foobar').setComponents([new ActionRowBuilder()]).toJSON(),
).toThrowError();
expect(() => modal().setTitle('test').setCustomId('foobar').toJSON()).toThrowError();
// @ts-expect-error
expect(() => modal().setTitle('test').setCustomId(42).toJSON()).toThrowError();
@@ -87,11 +83,11 @@ describe('Modals', () => {
modal()
.setTitle(modalData.title)
.setCustomId('custom id')
.setComponents(
new ActionRowBuilder<ModalActionRowComponentBuilder>().addComponents(
.setComponents([
new ActionRowBuilder<ModalActionRowComponentBuilder>().addComponents([
new TextInputBuilder().setCustomId('custom id').setLabel('label').setStyle(TextInputStyle.Paragraph),
),
)
]),
])
.toJSON(),
).toEqual(modalData);
});