feat: articles format option with markdown new default
This commit is contained in:
1 parent
68401d66e0
commit
7e9bd9ba30
61 files changed
+2269
-243
No files matched your search
@@ -0,0 +1,23 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const request = vi.fn()
|
||||
|
||||
vi.mock('@/composables/useApi', () => ({
|
||||
useApi: () => ({ request }),
|
||||
}))
|
||||
|
||||
import { useArticles } from '@/composables/useArticles'
|
||||
|
||||
describe('useArticles', () => {
|
||||
beforeEach(() => {
|
||||
request.mockReset()
|
||||
})
|
||||
|
||||
it('asks the API for html bodies when listing articles', async () => {
|
||||
request.mockResolvedValue([])
|
||||
|
||||
await useArticles().listArticles()
|
||||
|
||||
expect(request).toHaveBeenCalledWith('/v1/article/?format=html')
|
||||
})
|
||||
})
|
||||
@@ -79,7 +79,7 @@ export function useArticleDraft(articleId: number) {
|
||||
async function save(): Promise<SaveOutcome> {
|
||||
businessState.value = 'saving'
|
||||
try {
|
||||
await request<Article>(`/v1/article/${articleId}`, {
|
||||
await request<Article>(`/v1/article/${articleId}?format=html`, {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ body: body.value }),
|
||||
|
||||
@@ -13,7 +13,7 @@ export function useArticles() {
|
||||
const { request } = useApi()
|
||||
|
||||
function listArticles(): Promise<Article[]> {
|
||||
return request<Article[]>('/v1/article/')
|
||||
return request<Article[]>('/v1/article/?format=html')
|
||||
}
|
||||
|
||||
return { listArticles }
|
||||
|
||||
Reference in new issue
Block a user