-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathpreferences.test.ts
More file actions
53 lines (42 loc) · 1.29 KB
/
preferences.test.ts
File metadata and controls
53 lines (42 loc) · 1.29 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { describe, expect, it } from 'vitest';
import { createAgent } from '~/index';
const TEST_CREDENTIALS = {
alice: {
handle: 'alice.tsky.dev',
did: 'did:plc:jguhdmnjclquqf5lsvkyxqy3',
password: 'alice_and_bob',
},
bob: {
handle: 'bob.tsky.dev',
did: 'did:plc:2ig7akkyfq256j42uxvc4g2h',
password: 'alice_and_bob',
},
};
describe('preferences', () => {
it('.get()', async () => {
const agent = await createAgent({
identifier: TEST_CREDENTIALS.alice.handle,
password: TEST_CREDENTIALS.alice.password,
});
const preferences = await agent.user.preferences.get();
expect(preferences).toBeDefined();
});
it('.set()', async () => {
const agent = await createAgent({
identifier: TEST_CREDENTIALS.alice.handle,
password: TEST_CREDENTIALS.alice.password,
});
const payload = {
$type: 'app.bsky.actor.defs.adultContentPref',
enabled: false,
};
await agent.user.preferences.set([payload]);
const preferences = await agent.user.preferences.get();
expect(preferences).toBeDefined();
const pref = preferences.find((p) => p.$type === payload.$type);
expect(pref).toBeDefined();
expect(pref).toHaveProperty('enabled');
// @ts-ignore
expect(pref.enabled).toBe(payload.enabled);
});
});