Publish current project state

This commit is contained in:
2026-09-14 10:47:21 +08:00
parent 0dd188c46f
commit 4ad56ee9f8
186 changed files with 6289 additions and 1657 deletions
@@ -54,6 +54,37 @@ describe('#actions', () => {
});
});
describe('#update', () => {
it('sends correct actions if API is success', async () => {
axios.patch.mockResolvedValue({ data: { id: 2, content: 'updated' } });
await actions.update(
{ commit },
{ contactId: 1, noteId: 2, content: 'updated' }
);
expect(commit.mock.calls).toEqual([
[types.default.SET_CONTACT_NOTES_UI_FLAG, { isUpdating: true }],
[
types.default.EDIT_CONTACT_NOTE,
{ contactId: 1, data: { id: 2, content: 'updated' } },
],
[types.default.SET_CONTACT_NOTES_UI_FLAG, { isUpdating: false }],
]);
});
it('sends correct actions if API is error', async () => {
axios.patch.mockRejectedValue({ message: 'Incorrect header' });
await expect(
actions.update(
{ commit },
{ contactId: 1, noteId: 2, content: 'updated' }
)
).rejects.toThrow(Error);
expect(commit.mock.calls).toEqual([
[types.default.SET_CONTACT_NOTES_UI_FLAG, { isUpdating: true }],
[types.default.SET_CONTACT_NOTES_UI_FLAG, { isUpdating: false }],
]);
});
});
describe('#delete', () => {
it('sends correct actions if API is success', async () => {
axios.delete.mockResolvedValue({ data: notesData[0] });
@@ -24,6 +24,16 @@ describe('#mutations', () => {
expect(state.records[1]).toEqual([allNotes[0], allNotes[1]]);
});
});
describe('#EDIT_CONTACT_NOTE', () => {
it('replaces an existing note', () => {
const state = { records: { 1: [{ id: 2, content: 'old' }] } };
mutations[types.EDIT_CONTACT_NOTE](state, {
contactId: 1,
data: { id: 2, content: 'new' },
});
expect(state.records[1]).toEqual([{ id: 2, content: 'new' }]);
});
});
describe('#DELETE_CONTACT_NOTE', () => {
it('Delete existing note from records', () => {
const state = { records: { 1: [{ id: 2 }] } };