2021-05-11 10:25:22 -04:00
|
|
|
import useFetchMock from './hooks/use-fetch-mock'
|
2021-09-14 04:54:08 -04:00
|
|
|
import { withContextRoot } from './utils/with-context-root'
|
|
|
|
import WordCountModal from '../js/features/word-count-modal/components/word-count-modal'
|
|
|
|
|
|
|
|
const counts = {
|
|
|
|
headers: 4,
|
|
|
|
mathDisplay: 40,
|
|
|
|
mathInline: 400,
|
|
|
|
textWords: 4000,
|
|
|
|
}
|
|
|
|
|
|
|
|
const messages = [
|
|
|
|
'Lorem ipsum dolor sit amet.',
|
|
|
|
'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.',
|
|
|
|
].join('\n')
|
2021-01-06 05:38:25 -05:00
|
|
|
|
2021-09-14 04:54:08 -04:00
|
|
|
const project = {
|
|
|
|
_id: 'project-id',
|
|
|
|
name: 'A Project',
|
|
|
|
}
|
|
|
|
|
|
|
|
export const WordCount = args => {
|
2021-05-11 10:25:22 -04:00
|
|
|
useFetchMock(fetchMock => {
|
|
|
|
fetchMock.get(
|
|
|
|
'express:/project/:projectId/wordcount',
|
2021-09-14 04:54:08 -04:00
|
|
|
{ status: 200, body: { texcount: counts } },
|
|
|
|
{ delay: 500 }
|
|
|
|
)
|
|
|
|
})
|
2021-01-06 05:38:25 -05:00
|
|
|
|
2021-09-14 04:54:08 -04:00
|
|
|
return withContextRoot(<WordCountModal {...args} />, { project })
|
|
|
|
}
|
2021-01-06 05:38:25 -05:00
|
|
|
|
2021-09-14 04:54:08 -04:00
|
|
|
export const WordCountWithMessages = args => {
|
|
|
|
useFetchMock(fetchMock => {
|
|
|
|
fetchMock.get(
|
|
|
|
'express:/project/:projectId/wordcount',
|
|
|
|
{ status: 200, body: { texcount: { ...counts, messages } } },
|
|
|
|
{ delay: 500 }
|
2021-05-11 10:25:22 -04:00
|
|
|
)
|
|
|
|
})
|
2021-01-06 05:38:25 -05:00
|
|
|
|
2021-09-14 04:54:08 -04:00
|
|
|
return withContextRoot(<WordCountModal {...args} />, { project })
|
2021-01-06 05:38:25 -05:00
|
|
|
}
|
2021-09-14 04:54:08 -04:00
|
|
|
|
|
|
|
export const ErrorResponse = args => {
|
|
|
|
useFetchMock(fetchMock => {
|
|
|
|
fetchMock.get(
|
|
|
|
'express:/project/:projectId/wordcount',
|
|
|
|
{ status: 500 },
|
|
|
|
{ delay: 500 }
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
return withContextRoot(<WordCountModal {...args} />, { project })
|
2021-01-06 05:38:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
2022-03-28 06:23:21 -04:00
|
|
|
title: 'Editor / Modals / Word Count',
|
2021-03-05 08:00:21 -05:00
|
|
|
component: WordCountModal,
|
|
|
|
args: {
|
2021-04-27 03:52:58 -04:00
|
|
|
show: true,
|
2021-03-05 08:00:21 -05:00
|
|
|
},
|
2021-01-06 05:38:25 -05:00
|
|
|
}
|