Skip to content

Commit fa09bc2

Browse files
committed
test(builders): add validation tests for snowflake attachment IDs
1 parent f47a743 commit fa09bc2

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

packages/builders/__tests__/messages/fileBody.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ import { AttachmentBuilder, MessageBuilder } from '../../src/index.js';
66
test('AttachmentBuilder stores and exposes file data', () => {
77
const data = Buffer.from('hello world');
88
const attachment = new AttachmentBuilder()
9-
.setId('0')
9+
.setId(1)
1010
.setFilename('greeting.txt')
1111
.setFileData(data)
1212
.setFileContentType('text/plain');
1313

1414
expect(attachment.getRawFile()).toStrictEqual({
1515
contentType: 'text/plain',
1616
data,
17-
key: 'files[0]',
17+
key: 'files[1]',
1818
name: 'greeting.txt',
1919
});
2020

@@ -27,7 +27,7 @@ test('AttachmentBuilder stores and exposes file data', () => {
2727
test('MessageBuilder.toFileBody returns JSON body and files', () => {
2828
const msg = new MessageBuilder().setContent('here is a file').addAttachments(
2929
new AttachmentBuilder()
30-
.setId('0')
30+
.setId(0)
3131
.setFilename('file.bin')
3232
.setFileData(Buffer.from([1, 2, 3]))
3333
.setFileContentType('application/octet-stream'),
@@ -47,7 +47,9 @@ test('MessageBuilder.toFileBody returns JSON body and files', () => {
4747
});
4848

4949
test('MessageBuilder.toFileBody returns empty files when attachments reference existing uploads', () => {
50-
const msg = new MessageBuilder().addAttachments(new AttachmentBuilder().setId('123').setFilename('existing.png'));
50+
const msg = new MessageBuilder().addAttachments(
51+
new AttachmentBuilder().setId('12345678901234567890').setFilename('existing.png'),
52+
);
5153

5254
const { body, files } = msg.toFileBody();
5355
expect(body).toEqual(msg.toJSON());

packages/builders/__tests__/messages/message.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ describe('Message', () => {
6464
row.addPrimaryButtonComponents((button) => button.setCustomId('abc').setLabel('def')),
6565
)
6666
.setStickerIds('123', '456')
67-
.addAttachments((attachment) => attachment.setId('hi!').setFilename('abc'))
67+
.addAttachments((attachment) => attachment.setId(0).setFilename('abc'))
6868
.setFlags(MessageFlags.Ephemeral)
6969
.setEnforceNonce(false)
7070
.updatePoll((poll) => poll.addAnswers({ poll_media: { text: 'foo' } }).setQuestion({ text: 'foo' }));
@@ -83,7 +83,7 @@ describe('Message', () => {
8383
},
8484
],
8585
sticker_ids: ['123', '456'],
86-
attachments: [{ id: 'hi!', filename: 'abc' }],
86+
attachments: [{ id: 0, filename: 'abc' }],
8787
flags: 64,
8888
enforce_nonce: false,
8989
poll: {

0 commit comments

Comments
 (0)