Skip to content

Commit abb6f66

Browse files
committed
test: update tests
1 parent d60ab7f commit abb6f66

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

test/client.test.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,18 @@ describe('client', () => {
127127
})
128128
})
129129

130-
function mockChatInputCommandInteraction(commandName: string, options: Record<string, any> = {}) {
130+
function mockChatInputCommandInteraction(commandName: string, options: Record<string, any> = {}, withResponse = false) {
131131
const messageMock:
132132
& InteractionResponse
133133
& InteractionCallbackResponse
134134
& Message = {
135-
edit: vi.fn(() => Promise.resolve({})),
136-
resource: {
137-
message: {
138-
edit: vi.fn(() => Promise.resolve({})),
139-
},
140-
},
135+
...withResponse
136+
? { resource: {
137+
message: {
138+
edit: vi.fn(() => Promise.resolve({})),
139+
},
140+
} }
141+
: { edit: vi.fn(() => Promise.resolve({})) },
141142
} as any
142143
let deferred = false
143144
let replied = false

test/reply.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,19 @@ describe('reply', () => {
107107
content: 'Updated reply!',
108108
})
109109
})
110+
111+
it('should edit a reactive file reply', async () => {
112+
const [interaction, mock] = mockInteraction()
113+
const client = new MockClient()
114+
const file = ref('file.txt')
115+
// @ts-expect-error - this shouldn't error
116+
reply.file(file).call(client, interaction, client)
117+
expect(mock.reply).toHaveBeenCalledExactlyOnceWith({
118+
files: ['file.txt'],
119+
})
120+
file.value = 'updated-file.txt'
121+
await expect.poll(() => mockEditFunction).toHaveBeenCalledExactlyOnceWith({
122+
files: ['updated-file.txt'],
123+
})
124+
})
110125
})

0 commit comments

Comments
 (0)