|
| 1 | +import { expectAssignable, expectError, expectType } from 'tsd'; |
| 2 | +import type { SlackEvent, UserConnectionEvent, UserConnectionStatusRequestedEvent } from '../../src/index'; |
| 3 | + |
| 4 | +const connect: UserConnectionEvent = { |
| 5 | + type: 'user_connection', |
| 6 | + subtype: 'connect', |
| 7 | + user: 'U0123456789', |
| 8 | + trigger_id: '1293638028594.1249184885746.0d121a0e01d2e7a795ecc7a62880a406', |
| 9 | + event_ts: '1764264284.841251', |
| 10 | +}; |
| 11 | +expectAssignable<SlackEvent>(connect); |
| 12 | + |
| 13 | +const disconnect: UserConnectionEvent = { |
| 14 | + type: 'user_connection', |
| 15 | + subtype: 'disconnect', |
| 16 | + enterprise_id: 'E0123456789', |
| 17 | + user: 'U0123456789', |
| 18 | + event_ts: '1764264317.061589', |
| 19 | +}; |
| 20 | +expectAssignable<SlackEvent>(disconnect); |
| 21 | + |
| 22 | +expectError<UserConnectionEvent>({ |
| 23 | + type: 'user_connection', |
| 24 | + subtype: 'connect', |
| 25 | + user: 'U0123456789', |
| 26 | + event_ts: '1764264284.841251', |
| 27 | +}); |
| 28 | + |
| 29 | +declare const userConnection: UserConnectionEvent; |
| 30 | +if (userConnection.subtype === 'connect') { |
| 31 | + expectType<string>(userConnection.trigger_id); |
| 32 | +} |
| 33 | + |
| 34 | +const statusRequested: UserConnectionStatusRequestedEvent = { |
| 35 | + type: 'user_connection_status_requested', |
| 36 | + user: 'U0123456789', |
| 37 | + event_ts: '1764264284.841251', |
| 38 | +}; |
| 39 | +expectAssignable<SlackEvent>(statusRequested); |
| 40 | + |
| 41 | +expectError<UserConnectionStatusRequestedEvent>({ |
| 42 | + type: 'user_connection_status_requested', |
| 43 | +}); |
0 commit comments