File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ export interface Client {
3737 readonly tags : v1 . TagRepository ;
3838 readonly followedTags : v1 . FollowedTagRepository ;
3939 readonly push : v1 . PushRepository ;
40+ readonly profile : v1 . ProfileRepository ;
4041 } ;
4142 readonly v2 : {
4243 readonly filters : v2 . FilterRepository ;
Original file line number Diff line number Diff line change @@ -32,3 +32,4 @@ export * from "./suggestion-repository";
3232export * from "./tag-repository" ;
3333export * from "./timeline-repository" ;
3434export * from "./trend-repository" ;
35+ export * from "./profile-repository" ;
Original file line number Diff line number Diff line change 1+ import { type HttpMetaParams } from "../../../interfaces" ;
2+
3+ export interface ProfileRepository {
4+ avatar : {
5+ /**https://github.com/mastodon/mastodon/pull/25124 */
6+ remove ( meta ?: HttpMetaParams ) : Promise < void > ;
7+ } ;
8+
9+ header : {
10+ /**https://github.com/mastodon/mastodon/pull/25124 */
11+ remove ( meta ?: HttpMetaParams ) : Promise < void > ;
12+ } ;
13+ }
Original file line number Diff line number Diff line change 1+ const TRANSPARENT_1X1_PNG =
2+ "data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==" ;
3+
4+ export const getMockImage = async ( ) : Promise < Blob > => {
5+ const response = await fetch ( TRANSPARENT_1X1_PNG ) ;
6+ return await response . blob ( ) ;
7+ } ;
Original file line number Diff line number Diff line change 1+ import { getMockImage } from "../../../test-utils/image" ;
2+
3+ describe ( "profile" , ( ) => {
4+ it ( "can remove avatar" , ( ) => {
5+ sessions . use ( async ( client ) => {
6+ const profile1 = await client . rest . v1 . accounts . updateCredentials ( {
7+ avatar : await getMockImage ( ) ,
8+ } ) ;
9+ await client . rest . v1 . profile . avatar . remove ( ) ;
10+ const profile2 = await client . rest . v1 . accounts . verifyCredentials ( ) ;
11+ expect ( profile1 . avatar ) . not . toBe ( profile2 . avatar ) ;
12+ } ) ;
13+ } ) ;
14+
15+ it ( "can remove header" , ( ) => {
16+ sessions . use ( async ( client ) => {
17+ const profile1 = await client . rest . v1 . accounts . updateCredentials ( {
18+ header : await getMockImage ( ) ,
19+ } ) ;
20+ await client . rest . v1 . profile . header . remove ( ) ;
21+ const profile2 = await client . rest . v1 . accounts . verifyCredentials ( ) ;
22+ expect ( profile1 . header ) . not . toBe ( profile2 . header ) ;
23+ } ) ;
24+ } ) ;
25+ } ) ;
Original file line number Diff line number Diff line change 1- const TRANSPARENT_1X1_PNG =
2- "data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==" ;
3-
4- const createFile = async ( ) => {
5- const response = await fetch ( TRANSPARENT_1X1_PNG ) ;
6- const file = await response . blob ( ) ;
7- return file ;
8- } ;
1+ import { getMockImage } from "../../../test-utils/image" ;
92
103describe ( "media" , ( ) => {
114 it ( "creates a media attachment" , async ( ) => {
12- const file = await createFile ( ) ;
5+ const file = await getMockImage ( ) ;
136 let media = await admin . v2 . media . create ( { file } ) ;
147
158 media = await admin . v1 . media . $select ( media . id ) . fetch ( ) ;
@@ -23,7 +16,7 @@ describe("media", () => {
2316
2417 it ( "creates media attachment without polling" , ( ) => {
2518 return sessions . use ( async ( session ) => {
26- const file = await createFile ( ) ;
19+ const file = await getMockImage ( ) ;
2720 const media = await session . rest . v2 . media . create ( { file } ) ;
2821 expect ( media . type ) . toBe ( "image" ) ;
2922 } ) ;
Original file line number Diff line number Diff line change 11import crypto from "node:crypto" ;
22
33import { type mastodon } from "../../src" ;
4-
5- const TRANSPARENT_1X1_PNG =
6- "data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==" ;
4+ import { getMockImage } from "../../test-utils/image" ;
75
86describe ( "websocket" , ( ) => {
97 it ( "streams public" , ( ) => {
@@ -51,7 +49,7 @@ describe("websocket", () => {
5149 . toArray ( ) ;
5250
5351 const media = await session . rest . v2 . media . create ( {
54- file : TRANSPARENT_1X1_PNG ,
52+ file : await getMockImage ( ) ,
5553 } ) ;
5654 const status = await session . rest . v1 . statuses . create ( {
5755 status : random ,
@@ -115,7 +113,7 @@ describe("websocket", () => {
115113 . toArray ( ) ;
116114
117115 const media = await session . rest . v2 . media . create ( {
118- file : TRANSPARENT_1X1_PNG ,
116+ file : await getMockImage ( ) ,
119117 } ) ;
120118
121119 const status = await session . rest . v1 . statuses . create ( {
You can’t perform that action at this time.
0 commit comments