@@ -1,6 +1,6 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { TwitterClient } from '../src/lib/twitter-client.js';
|
||||
import { validCookies } from './twitter-client-fixtures.js';
|
||||
import { testRelayBaseUrl } from './twitter-client-fixtures.js';
|
||||
|
||||
const originalFetch = global.fetch;
|
||||
|
||||
@@ -34,7 +34,7 @@ describe('TwitterClient uploadMedia', () => {
|
||||
ok: true,
|
||||
});
|
||||
|
||||
const client = new TwitterClient({ cookies: validCookies });
|
||||
const client = new TwitterClient({ relayBaseUrl: testRelayBaseUrl });
|
||||
const data = new Uint8Array([1, 2, 3, 4]);
|
||||
const result = await client.uploadMedia({ data, mimeType: 'image/png', alt: 'alt text' });
|
||||
|
||||
@@ -43,7 +43,7 @@ describe('TwitterClient uploadMedia', () => {
|
||||
expect(mockFetch).toHaveBeenCalledTimes(4);
|
||||
|
||||
const [initUrl, initOptions] = mockFetch.mock.calls[0];
|
||||
expect(String(initUrl)).toContain('upload.twitter.com');
|
||||
expect(String(initUrl)).toBe(`${testRelayBaseUrl}/i/media/upload.json`);
|
||||
expect(initOptions.method).toBe('POST');
|
||||
expect(initOptions.body).toBeInstanceOf(URLSearchParams);
|
||||
expect((initOptions.body as URLSearchParams).get('command')).toBe('INIT');
|
||||
@@ -87,7 +87,7 @@ describe('TwitterClient uploadMedia', () => {
|
||||
json: async () => ({ processing_info: { state: 'succeeded' } }),
|
||||
});
|
||||
|
||||
const client = new TwitterClient({ cookies: validCookies });
|
||||
const client = new TwitterClient({ relayBaseUrl: testRelayBaseUrl });
|
||||
const data = new Uint8Array([1, 2, 3, 4, 5]);
|
||||
const result = await client.uploadMedia({ data, mimeType: 'video/mp4', alt: 'ignored' });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user