it('calls FakeNote.post with projectId, storyId and note', async () => { const FakeNote = { post: sinon.stub().resolves(note) }; const fakeDispatch = sinon.stub().resolves({}); await Note.createNote(projectId, storyId, note) (fakeDispatch, null, { Note: FakeNote }); expect(FakeNote.post).toHaveBeenCalledWith(projectId, storyId, note); });
it('dispatch createNoteSuccess with storyId and note', async () => { const FakeNote = { post: sinon.stub().resolves(note) }; const fakeDispatch = sinon.stub().resolves({}); await Note.createNote(projectId, storyId, note) (fakeDispatch, null, { Note: FakeNote }); expect(fakeDispatch).toHaveBeenCalledWith(Note.createNoteSuccess(storyId, note)); });
it('dispatches storyFailure when promise fails', async () => { const error = { error: "boom" }; const FakeNote = { post: sinon.stub().rejects(error) }; const fakeDispatch = sinon.stub().resolves({}); await Note.createNote(projectId, storyId, note) (fakeDispatch, null, { Note: FakeNote }); expect(fakeDispatch).toHaveBeenCalledWith(Story.storyFailure(storyId, error)); });