-
Notifications
You must be signed in to change notification settings - Fork 477
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #237 from hql287/reimplement-invoice-update
Reimplemented invoice update action. Fix #227
- Loading branch information
Showing
9 changed files
with
289 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ it('getInvoices should create GET_INVOICES action', () => { | |
}); | ||
}); | ||
|
||
it('saveInvoice should create SAVE_INVOICE action', () => { | ||
it('saveInvoice should create INVOICE_SAVE action', () => { | ||
const invoiceData = { | ||
_id: 'jon_snow', | ||
fulname: 'Jon Snow', | ||
|
@@ -19,21 +19,73 @@ it('saveInvoice should create SAVE_INVOICE action', () => { | |
}); | ||
}); | ||
|
||
it('deleteInvoice should create DELETE_INVOICE action', () => { | ||
it('newInvoiceFromContact should create INVOICE_NEW_FROM_CONTACT action', () => { | ||
const contactData = { | ||
_id: 'jon_snow', | ||
fulname: 'Jon Snow', | ||
email: '[email protected]', | ||
}; | ||
expect(actions.newInvoiceFromContact(contactData)).toEqual({ | ||
type: ACTION_TYPES.INVOICE_NEW_FROM_CONTACT, | ||
payload: contactData, | ||
}); | ||
}); | ||
|
||
it('deleteInvoice should create INVOICE_DELETE action', () => { | ||
expect(actions.deleteInvoice('jon_snow')).toEqual({ | ||
type: ACTION_TYPES.INVOICE_DELETE, | ||
payload: 'jon_snow', | ||
}); | ||
}); | ||
|
||
it('newInvoiceFromContact should create INVOICE_NEW_FROM_CONTACT action', () => { | ||
const contact = { | ||
id: 'abcxyz', | ||
name: 'Jon Snow', | ||
company: 'HBO', | ||
it('editInvoice should create INVOICE_EDIT action', () => { | ||
const invoiceData = { | ||
_id: 'jon_snow', | ||
fulname: 'Jon Snow', | ||
email: '[email protected]', | ||
}; | ||
expect(actions.newInvoiceFromContact(contact)).toEqual({ | ||
type: ACTION_TYPES.INVOICE_NEW_FROM_CONTACT, | ||
payload: contact, | ||
expect(actions.editInvoice(invoiceData)).toEqual({ | ||
type: ACTION_TYPES.INVOICE_EDIT, | ||
payload: invoiceData, | ||
}); | ||
}); | ||
|
||
it('updateInvoice should create INVOICE_UPDATE action', () => { | ||
const invoiceData = { | ||
_id: 'jon_snow', | ||
fulname: 'Jon Snow', | ||
email: '[email protected]', | ||
}; | ||
expect(actions.updateInvoice(invoiceData)).toEqual({ | ||
type: ACTION_TYPES.INVOICE_UPDATE, | ||
payload: invoiceData, | ||
}); | ||
}); | ||
|
||
it('setInvoiceStatus should create INVOICE_SET_STATUS action', () => { | ||
const invoiceID = 'jon_snow'; | ||
const status = 'pending'; | ||
expect(actions.setInvoiceStatus(invoiceID, status)).toEqual({ | ||
type: ACTION_TYPES.INVOICE_SET_STATUS, | ||
payload: { | ||
invoiceID: 'jon_snow', | ||
status: 'pending', | ||
}, | ||
}); | ||
}); | ||
|
||
it('saveInvoiceConfigs should create INVOICE_CONFIGS_SAVE action', () => { | ||
const invoiceID = 'jon_snow'; | ||
const configs = { | ||
color: 'red' | ||
}; | ||
expect(actions.saveInvoiceConfigs(invoiceID, configs)).toEqual({ | ||
type: ACTION_TYPES.INVOICE_CONFIGS_SAVE, | ||
payload: { | ||
invoiceID: 'jon_snow', | ||
configs: { | ||
color: 'red' | ||
} | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,39 @@ | ||
import * as ACTION_TYPES from '../constants/actions.jsx'; | ||
import { createAction } from 'redux-actions'; | ||
|
||
// Get All Invoices | ||
export const getInvoices = createAction(ACTION_TYPES.INVOICE_GET_ALL); | ||
|
||
// Save an Invoice | ||
export const saveInvoice = createAction( | ||
ACTION_TYPES.INVOICE_SAVE, | ||
invoiceData => invoiceData | ||
); | ||
|
||
export const saveInvoiceConfigs = createAction( | ||
ACTION_TYPES.INVOICE_CONFIGS_SAVE, | ||
(invoiceID, configs) => ({ invoiceID, configs }) | ||
export const newInvoiceFromContact = createAction( | ||
ACTION_TYPES.INVOICE_NEW_FROM_CONTACT, | ||
contact => contact | ||
); | ||
|
||
export const deleteInvoice = createAction( | ||
ACTION_TYPES.INVOICE_DELETE, | ||
invoiceID => invoiceID | ||
); | ||
|
||
// Edit an Invoice | ||
export const editInvoice = createAction( | ||
ACTION_TYPES.INVOICE_EDIT, | ||
invoiceData => invoiceData | ||
); | ||
|
||
export const updateInvoice = createAction( | ||
ACTION_TYPES.INVOICE_UPDATE, | ||
(invoiceID, data) => ({ invoiceID, data }) | ||
); | ||
|
||
// New Invoice from Contact | ||
export const newInvoiceFromContact = createAction( | ||
ACTION_TYPES.INVOICE_NEW_FROM_CONTACT, | ||
contact => contact | ||
updatedInvoice => updatedInvoice | ||
); | ||
|
||
// Delete an invoice | ||
export const deleteInvoice = createAction( | ||
ACTION_TYPES.INVOICE_DELETE, | ||
invoiceID => invoiceID | ||
); | ||
|
||
// set the status of an invoice (pending/paid/etc.) | ||
export const setInvoiceStatus = createAction( | ||
ACTION_TYPES.INVOICE_SET_STATUS, | ||
(invoiceID, status) => ({ invoiceID, status }) | ||
); | ||
|
||
export const saveInvoiceConfigs = createAction( | ||
ACTION_TYPES.INVOICE_CONFIGS_SAVE, | ||
(invoiceID, configs) => ({ invoiceID, configs }) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.