diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-08-08 15:54:36 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-08 15:54:36 -0700 |
commit | bbe9861eef0e9f44b31259cb92221ee4094afac2 (patch) | |
tree | 2ddafcc3a9aa5fe19714203ea4bd616c3fcad4f9 /jest | |
parent | e51dbefd0ac1c04853237ed4889601da220f54ba (diff) | |
download | voidsky-bbe9861eef0e9f44b31259cb92221ee4094afac2.tar.zst |
Add alerts to embeds (#1138)
* Add alerts to embeds * Add images to the mock data * Fix types
Diffstat (limited to 'jest')
-rw-r--r-- | jest/test-pds.ts | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/jest/test-pds.ts b/jest/test-pds.ts index 21d90b93b..48b73e848 100644 --- a/jest/test-pds.ts +++ b/jest/test-pds.ts @@ -29,13 +29,13 @@ export async function createServer( plc: {port: port2}, }) - const profilePic = fs.readFileSync( + const pic = fs.readFileSync( path.join(__dirname, '..', 'assets', 'default-avatar.jpg'), ) return { pdsUrl, - mocker: new Mocker(pds, pdsUrl, profilePic), + mocker: new Mocker(pds, pdsUrl, pic), async close() { await pds.server.destroy() await plc.server.destroy() @@ -50,7 +50,7 @@ class Mocker { constructor( public pds: DevEnvTestPDS, public service: string, - public profilePic: Uint8Array, + public pic: Uint8Array, ) { this.agent = new BskyAgent({service}) } @@ -90,7 +90,7 @@ class Mocker { password: 'hunter2', }) await agent.upsertProfile(async () => { - const blob = await agent.uploadBlob(this.profilePic, { + const blob = await agent.uploadBlob(this.pic, { encoding: 'image/jpeg', }) return { @@ -151,6 +151,25 @@ class Mocker { }) } + async createImagePost(user: string, text: string) { + const agent = this.users[user]?.agent + if (!agent) { + throw new Error(`Not a user: ${user}`) + } + const blob = await agent.uploadBlob(this.pic, { + encoding: 'image/jpeg', + }) + return await agent.post({ + text, + langs: ['en'], + embed: { + $type: 'app.bsky.embed.images', + images: [{image: blob.data.blob, alt: ''}], + }, + createdAt: new Date().toISOString(), + }) + } + async createQuotePost( user: string, text: string, |