Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/builders/__tests__/components/button.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Button Components', () => {
button.toJSON();
}).not.toThrowError();

expect(() => new LinkButtonBuilder().setURL('https://google.com')).not.toThrowError();
expect(() => new LinkButtonBuilder().setLabel('label').setURL('https://google.com').toJSON()).not.toThrowError();
});

test('GIVEN invalid fields THEN build does throw', () => {
Expand Down Expand Up @@ -61,6 +61,13 @@ describe('Button Components', () => {
expect(() => new PrimaryButtonBuilder().setCustomId('hi').setDisabled(0).toJSON()).toThrowError();
// @ts-expect-error: Invalid emoji
expect(() => new PrimaryButtonBuilder().setCustomId('hi').setEmoji('foo').toJSON()).toThrowError();

expect(() =>
new LinkButtonBuilder()
.setLabel('label')
.setURL(`https://google.com/${'a'.repeat(512)}`)
.toJSON(),
).toThrowError();
});

test('GiVEN valid input THEN valid JSON outputs are given', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/builders/src/components/Assertions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const buttonDangerPredicate = buttonCustomIdPredicateBase.extend({ style: z.lite

const buttonLinkPredicate = buttonPredicateBase.extend({
style: z.literal(ButtonStyle.Link),
url: z.url({ protocol: /^(?:https?|discord)$/ }),
url: z.url({ protocol: /^(?:https?|discord)$/ }).max(512),
emoji: emojiPredicate.optional(),
label: labelPredicate,
});
Expand Down