mirror of
https://git.shipoclu.com/moon/plspace.git
synced 2026-08-13 02:42:30 +00:00
custom css works now
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { ApiClient } from './client'
|
||||
import { updateProfileFields } from './endpoints'
|
||||
|
||||
afterEach(() => {
|
||||
vi.unstubAllGlobals()
|
||||
})
|
||||
|
||||
describe('updateProfileFields', () => {
|
||||
it('uses the Pleroma/Mastodon indexed multipart representation', async () => {
|
||||
const fetchMock = vi.fn(async (_url: string, init?: RequestInit) => {
|
||||
expect(init?.method).toBe('PATCH')
|
||||
expect(init?.headers).toBeInstanceOf(Headers)
|
||||
expect((init?.headers as Headers).get('Authorization')).toBe('Bearer token')
|
||||
expect(init?.body).toBeInstanceOf(FormData)
|
||||
const form = init?.body as FormData
|
||||
expect([...form.entries()]).toEqual([
|
||||
['fields_attributes[0][name]', 'Website'],
|
||||
['fields_attributes[0][value]', 'https://example.test'],
|
||||
['fields_attributes[1][name]', 'plspace:css1'],
|
||||
['fields_attributes[1][value]', 'body { color: pink; }'],
|
||||
])
|
||||
return new Response(JSON.stringify({ id: 'account-1', fields: [] }), {
|
||||
status: 200,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
})
|
||||
})
|
||||
vi.stubGlobal('fetch', fetchMock)
|
||||
|
||||
await updateProfileFields(new ApiClient('example.test', 'token'), [
|
||||
{ name: 'Website', value: 'https://example.test' },
|
||||
{ name: 'plspace:css1', value: 'body { color: pink; }' },
|
||||
])
|
||||
|
||||
expect(fetchMock).toHaveBeenCalledWith(
|
||||
'https://example.test/api/v1/accounts/update_credentials',
|
||||
expect.any(Object),
|
||||
)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user