mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-19 04:53:30 +01:00
fix: Adjust label predicates (#11318)
* fix: labels in 14 * test: add variable for at limit * docs(jsonOptionValidator): deprecate * fix: export `selectMenuStringOptionPredicate` * fix: export everything Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com> --------- Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com>
This commit is contained in:
@@ -6,6 +6,10 @@ const selectMenu = () => new StringSelectMenuBuilder();
|
||||
const selectMenuOption = () => new StringSelectMenuOptionBuilder();
|
||||
|
||||
const longStr = 'a'.repeat(256);
|
||||
const selectMenuOptionLabelAtLimit = 'a'.repeat(100);
|
||||
const selectMenuOptionLabelAboveLimit = 'a'.repeat(101);
|
||||
const selectMenuOptionValueAboveLimit = 'a'.repeat(101);
|
||||
const selectMenuOptionDescriptionAboveLimit = 'a'.repeat(101);
|
||||
|
||||
const selectMenuOptionData: APISelectMenuOption = {
|
||||
label: 'test',
|
||||
@@ -53,12 +57,12 @@ describe('Select Menu Components', () => {
|
||||
expect(() => selectMenu().setDisabled()).not.toThrowError();
|
||||
expect(() => selectMenu().setPlaceholder('description')).not.toThrowError();
|
||||
const option = selectMenuOption()
|
||||
.setLabel('test')
|
||||
.setLabel(selectMenuOptionLabelAtLimit)
|
||||
.setValue('test')
|
||||
.setDefault(true)
|
||||
.setEmoji({ name: 'test' })
|
||||
.setDescription('description');
|
||||
expect(() => selectMenu().addOptions(option)).not.toThrowError();
|
||||
expect(() => selectMenu().setCustomId('customId').addOptions(option).toJSON()).not.toThrowError();
|
||||
expect(() => selectMenu().setOptions(option)).not.toThrowError();
|
||||
expect(() => selectMenu().setOptions({ label: 'test', value: 'test' })).not.toThrowError();
|
||||
expect(() => selectMenu().addOptions([option])).not.toThrowError();
|
||||
@@ -156,13 +160,13 @@ describe('Select Menu Components', () => {
|
||||
|
||||
expect(() => {
|
||||
selectMenuOption()
|
||||
.setLabel(longStr)
|
||||
.setValue(longStr)
|
||||
.setLabel(selectMenuOptionLabelAboveLimit)
|
||||
.setValue(selectMenuOptionValueAboveLimit)
|
||||
// @ts-expect-error: Invalid default value
|
||||
.setDefault(-1)
|
||||
// @ts-expect-error: Invalid emoji
|
||||
.setEmoji({ name: 1 })
|
||||
.setDescription(longStr);
|
||||
.setDescription(selectMenuOptionDescriptionAboveLimit);
|
||||
}).toThrowError();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user