feat(editor): a reference made in the citations draft saves with it
This commit is contained in:
1 parent
8c3fcca0b9
commit
70eb2fcbb4
15 files changed
+671
-162
No files matched your search
@@ -152,55 +152,62 @@ describe('closeCitations', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('a creation started over the citations dialog', () => {
|
||||
it('hands its id to the form that started it; no « added » notice', async () => {
|
||||
describe('a creation started over the citations dialog (Rev 6: a draft creation)', () => {
|
||||
const pending = {
|
||||
id: 'ref-p',
|
||||
type: 'book',
|
||||
citation: 'Neuf',
|
||||
doi: null,
|
||||
url: null,
|
||||
} as const
|
||||
|
||||
it('holds its citing form and the pending value; created() never cites', async () => {
|
||||
cited()
|
||||
const cite = vi.fn()
|
||||
act(() => nav.references.start(null, cite))
|
||||
act(() => nav.references.start(null, cite, pending))
|
||||
expect(nav.state).toMatchObject({
|
||||
tab: 'findings',
|
||||
reference: { create: true },
|
||||
})
|
||||
await act(async () => nav.references.created('ref-new'))
|
||||
expect(cite).toHaveBeenCalledWith('ref-new')
|
||||
expect(nav.references.added).toBeNull()
|
||||
expect(nav.references.drafting()).toEqual({ initial: pending, cite })
|
||||
act(() => nav.references.close(true))
|
||||
expect(nav.references.drafting()).toBeNull()
|
||||
expect(nav.state.reference).toBeNull()
|
||||
expect(nav.state.finding).toMatchObject({ citations: true })
|
||||
expect(cite).not.toHaveBeenCalled()
|
||||
expect(nav.references.added).toBeNull()
|
||||
})
|
||||
|
||||
it('a creation closed or replaced forgets its citing form', async () => {
|
||||
it('a new one has no initial value', () => {
|
||||
cited()
|
||||
const cite = vi.fn()
|
||||
act(() => nav.references.start(null, cite))
|
||||
act(() => nav.references.close(true))
|
||||
await act(async () => nav.references.created('ref-x'))
|
||||
expect(cite).not.toHaveBeenCalled()
|
||||
act(() => nav.references.start(null, cite))
|
||||
expect(nav.references.drafting()).toEqual({ initial: null, cite })
|
||||
})
|
||||
|
||||
it('a creation replaced forgets its citing form', () => {
|
||||
cited()
|
||||
act(() => nav.references.start(null, vi.fn(), pending))
|
||||
act(() => nav.references.replace(null))
|
||||
await act(async () => nav.references.created('ref-y'))
|
||||
expect(cite).not.toHaveBeenCalled()
|
||||
expect(nav.references.drafting()).toBeNull()
|
||||
})
|
||||
|
||||
it('a Back that removes the creation dialog forgets its citing form', async () => {
|
||||
it('a Back that removes the creation dialog forgets its citing form', () => {
|
||||
cited()
|
||||
const cite = vi.fn()
|
||||
act(() => nav.references.start(null, cite))
|
||||
act(() => nav.references.start(null, vi.fn(), pending))
|
||||
act(() => navigate(-1))
|
||||
expect(nav.state.reference).toBeNull()
|
||||
await act(async () => nav.references.created('ref-z'))
|
||||
expect(cite).not.toHaveBeenCalled()
|
||||
expect(nav.references.added).toMatchObject({ id: 'ref-z' })
|
||||
expect(nav.references.drafting()).toBeNull()
|
||||
})
|
||||
|
||||
it('a later creation from the library sets the notice, cites nothing', async () => {
|
||||
it('a creation from the library is no draft; created() sets the notice', async () => {
|
||||
cited()
|
||||
const cite = vi.fn()
|
||||
act(() => nav.references.start(null, cite))
|
||||
act(() => nav.references.start(null, vi.fn()))
|
||||
act(() => nav.references.close(true))
|
||||
act(() => nav.selectTab('references'))
|
||||
act(() => nav.references.start(null))
|
||||
expect(nav.references.drafting()).toBeNull()
|
||||
await act(async () => nav.references.created('ref-lib'))
|
||||
expect(cite).not.toHaveBeenCalled()
|
||||
expect(nav.references.added).toMatchObject({ id: 'ref-lib' })
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user