forked from hql287/Manta
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reflect changes on invoice immediately when profile's changed. (hql28…
…7#245) * Notify previewWindow about profile chages * Added profile changes handler in previewWindow * Added tests to SettingsMW * Added ActionCreator & Reducer tests to previewWindow
- Loading branch information
Showing
10 changed files
with
268 additions
and
28 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import * as ACTION_TYPES from '../../constants/actions.jsx'; | ||
import * as actions from '../index.jsx'; | ||
|
||
it('updateInvoice should create INVOICE_UPDATE action', () => { | ||
const invoiceData = { test: 'test'} | ||
expect(actions.updateInvoice(invoiceData)).toEqual({ | ||
type: ACTION_TYPES.INVOICE_UPDATE, | ||
payload: invoiceData, | ||
}); | ||
}); | ||
|
||
it('updateConfigs should create SETTINGS_UPDATE_CONFIGS action', () => { | ||
const configs = { test: 'test'} | ||
expect(actions.updateConfigs(configs)).toEqual({ | ||
type: ACTION_TYPES.SETTINGS_UPDATE_CONFIGS, | ||
payload: configs, | ||
}); | ||
}); | ||
|
||
it('updateProfile should create SETTINGS_UPDATE_PROFILE action', () => { | ||
const profile = { test: 'test'} | ||
expect(actions.updateProfile(profile)).toEqual({ | ||
type: ACTION_TYPES.SETTINGS_UPDATE_PROFILE, | ||
payload: profile, | ||
}); | ||
}); | ||
|
||
it('changeUILanguage should create UI_CHANGE_LANGUAGE action', () => { | ||
const language = 'fr'; | ||
expect(actions.changeUILanguage(language)).toEqual({ | ||
type: ACTION_TYPES.UI_CHANGE_LANGUAGE, | ||
payload: language, | ||
}); | ||
}); | ||
|
||
it('reloadConfigs should create SETTINGS_RELOAD_CONFIGS action', () => { | ||
const newConfigs = { test: 'test'} | ||
expect(actions.reloadConfigs(newConfigs)).toEqual({ | ||
type: ACTION_TYPES.SETTINGS_RELOAD_CONFIGS, | ||
payload: newConfigs, | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
import * as ACTION_TYPES from '../../constants/actions.jsx'; | ||
import faker from 'faker'; | ||
import uuidv4 from 'uuid/v4'; | ||
import RootReducer, { | ||
getConfigs, | ||
getInvoice, | ||
getProfile, | ||
getUILang, | ||
getInvoiceLang, | ||
} from '../index.jsx'; | ||
|
||
describe('RootReducer should', () => { | ||
it('handle INVOICE_UPDATE action', () => { | ||
const currentState = { | ||
invoice: {}, | ||
configs: {}, | ||
}; | ||
const newState = RootReducer(currentState, { | ||
type: ACTION_TYPES.INVOICE_UPDATE, | ||
payload: { | ||
invoice: 'invoice', | ||
configs: 'configs', | ||
} | ||
}) | ||
expect(newState.invoice).toEqual({ | ||
invoice: 'invoice', | ||
configs: 'configs', | ||
}); | ||
expect(newState.configs).toEqual('configs'); | ||
}); | ||
|
||
it('handle UI_CHANGE_LANGUAGE action', () => { | ||
const currentState = { | ||
ui: { language: 'en' } | ||
}; | ||
const newState = RootReducer(currentState, { | ||
type: ACTION_TYPES.UI_CHANGE_LANGUAGE, | ||
payload: 'fr' | ||
}) | ||
expect(newState.ui.language).toEqual('fr'); | ||
}); | ||
|
||
it('handle SETTINGS_UPDATE_PROFILE action', () => { | ||
const currentState = { | ||
profile: 'Profile' | ||
}; | ||
const newState = RootReducer(currentState, { | ||
type: ACTION_TYPES.SETTINGS_UPDATE_PROFILE, | ||
payload: 'New Profile' | ||
}) | ||
expect(newState.profile).toEqual('New Profile'); | ||
}); | ||
|
||
it('handle SETTINGS_UPDATE_CONFIGS action', () => { | ||
const currentState = { | ||
configs: { template: 'minimal' } | ||
}; | ||
const newState = RootReducer(currentState, { | ||
type: ACTION_TYPES.SETTINGS_UPDATE_CONFIGS, | ||
payload: { | ||
name: 'template', | ||
value: 'business', | ||
} | ||
}) | ||
expect(newState.configs.template).toEqual('business'); | ||
}); | ||
|
||
it('handle SETTINGS_RELOAD_CONFIGS action', () => { | ||
const currentState = { | ||
profile: 'Profile', | ||
configs: { | ||
language: 'fr', | ||
template: 'minimal', | ||
dateFormat: 'DDMMYY', | ||
} | ||
}; | ||
const newState = RootReducer(currentState, { | ||
type: ACTION_TYPES.SETTINGS_RELOAD_CONFIGS, | ||
payload: { | ||
profile: 'New Profile', | ||
general: { language: 'en' }, | ||
invoice: { | ||
dateFormat: 'MMMM/DDDD/YYYY', | ||
template: 'business', | ||
} | ||
} | ||
}) | ||
expect(newState.profile).toEqual('New Profile'); | ||
expect(newState.configs.language).toEqual('en'); | ||
expect(newState.configs.template).toEqual('business'); | ||
expect(newState.configs.dateFormat).toEqual('MMMM/DDDD/YYYY'); | ||
}); | ||
}); | ||
|
||
describe('Selectors should', () => { | ||
let state; | ||
beforeEach(() => { | ||
state = { | ||
ui: { language: 'en' }, | ||
configs: { template: 'Business' }, | ||
invoice: { language: 'fr' }, | ||
profile: 'Profile', | ||
} | ||
}); | ||
it('getConfigs should return invoice current configs', () => { | ||
expect(getConfigs(state)).toEqual(state.configs); | ||
}); | ||
it('getInvoice should return invoice data', () => { | ||
expect(getInvoice(state)).toEqual(state.invoice); | ||
}); | ||
it('getProfile should return profile data', () => { | ||
expect(getProfile(state)).toEqual('Profile'); | ||
}); | ||
it('getUILang should return profile data', () => { | ||
expect(getUILang(state)).toEqual('en'); | ||
}); | ||
it('getInvoiceLang should return language of the invoice', () => { | ||
expect(getInvoiceLang(state)).toEqual('fr'); | ||
}); | ||
}); |
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