-
Notifications
You must be signed in to change notification settings - Fork 20
/
index.test-d.ts
36 lines (29 loc) · 1.29 KB
/
index.test-d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { expectType } from 'tsd';
import * as PusherPushNotifications from '.';
// Create a client
const beamsClient = new PusherPushNotifications.Client({
instanceId: 'YOUR_INSTANCE_ID',
});
// Lifecycle management
expectType<Promise<undefined>>(beamsClient.start());
expectType<Promise<undefined>>(beamsClient.stop());
expectType<Promise<undefined>>(beamsClient.clearAllState());
expectType<Promise<string>>(beamsClient.getDeviceId());
// Interest management
expectType<Promise<undefined>>(beamsClient.addDeviceInterest('hello'));
expectType<Promise<undefined>>(beamsClient.removeDeviceInterest('hello'));
expectType<Promise<Array<string>>>(beamsClient.getDeviceInterests());
expectType<Promise<undefined>>(beamsClient.setDeviceInterests(['a', 'b', 'c']));
expectType<Promise<undefined>>(beamsClient.clearDeviceInterests());
// Authenticated Users
const tokenProvider = new PusherPushNotifications.TokenProvider({
url: 'YOUR_BEAMS_AUTH_URL_HERE',
queryParams: { someQueryParam: 'parameter-content' },
headers: { someHeader: 'header-content' },
});
expectType<Promise<string>>(beamsClient.getUserId());
expectType<Promise<undefined>>(beamsClient.setUserId('alice', tokenProvider));
// Registration state
expectType<Promise<PusherPushNotifications.RegistrationState>>(
beamsClient.getRegistrationState()
);