-
Notifications
You must be signed in to change notification settings - Fork 685
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Reorganize redux, add address form - refactor(redux): Reorganize actions and reducers (#212) - feature(checkout): Add address form to checkout flow (#226) - test(redux): Add tests for redux actions (#239) * fixup
- Loading branch information
Showing
61 changed files
with
2,218 additions
and
758 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
8 changes: 8 additions & 0 deletions
8
...ncept/src/__mocks__/@magento/peregrine.js → ...a-concept/__mocks__/@magento/peregrine.js
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 |
---|---|---|
@@ -1,30 +1,30 @@ | ||
{ | ||
"name": "theme-frontend-venia", | ||
"version": "0.1.1", | ||
"description": "Venia PWA Concept Theme for Magento 2", | ||
"license": "(OSL-3.0 OR AFL-3.0)", | ||
"author": "Magento Commerce", | ||
"main": "src/index.js", | ||
"repository": "github:magento-research/pwa-studio", | ||
"bugs": { | ||
"url": "https://github.com/magento-research/pwa-studio/issues" | ||
}, | ||
"homepage": "https://github.com/magento-research/pwa-studio/tree/master/packages/venia-concept#readme", | ||
"scripts": { | ||
"build": "webpack --color --env.phase production", | ||
"clean": "rimraf web/js", | ||
"prepare": "npm-merge-driver install", | ||
"start": "webpack-dev-server --progress --color --env.phase development", | ||
"start:debug": "node --inspect-brk ./node_modules/.bin/webpack-dev-server --progress --color --env.phase development", | ||
"watch": "npm run -s start" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@magento/peregrine": "*", | ||
"@magento/pwa-buildpack": "*", | ||
"npm-merge-driver": "^2.3.5", | ||
"rimraf": "^2.6.2", | ||
"webpack": "3.11.0", | ||
"webpack-dev-server": "2.11.0" | ||
} | ||
"name": "theme-frontend-venia", | ||
"version": "0.1.1", | ||
"description": "Venia PWA Concept Theme for Magento 2", | ||
"license": "(OSL-3.0 OR AFL-3.0)", | ||
"author": "Magento Commerce", | ||
"main": "src/index.js", | ||
"repository": "github:magento-research/pwa-studio", | ||
"bugs": { | ||
"url": "https://github.com/magento-research/pwa-studio/issues" | ||
}, | ||
"homepage": "https://github.com/magento-research/pwa-studio/tree/master/packages/venia-concept#readme", | ||
"scripts": { | ||
"build": "webpack --color --env.phase production", | ||
"clean": "rimraf web/js", | ||
"prepare": "npm-merge-driver install", | ||
"start": "webpack-dev-server --progress --color --env.phase development", | ||
"start:debug": "node --inspect-brk ./node_modules/.bin/webpack-dev-server --progress --color --env.phase development", | ||
"watch": "npm run -s start" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@magento/peregrine": "*", | ||
"@magento/pwa-buildpack": "*", | ||
"npm-merge-driver": "^2.3.5", | ||
"rimraf": "^2.6.2", | ||
"webpack": "3.11.0", | ||
"webpack-dev-server": "2.11.0" | ||
} | ||
} |
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,7 @@ | ||
const initialState = {}; | ||
|
||
export const addReducer = jest.fn(); | ||
export const dispatch = jest.fn(); | ||
export const getState = jest.fn(() => initialState); | ||
|
||
export default { addReducer, dispatch, getState }; |
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
packages/venia-concept/src/actions/app/__tests__/actions.spec.js
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,20 @@ | ||
import actions from '../actions'; | ||
|
||
const payload = 'FOO'; | ||
const error = new Error('BAR'); | ||
|
||
test('toggleDrawer.toString() returns the proper action type', () => { | ||
expect(actions.toggleDrawer.toString()).toBe('APP/TOGGLE_DRAWER'); | ||
}); | ||
|
||
test('toggleDrawer() returns a proper action object', () => { | ||
expect(actions.toggleDrawer(payload)).toEqual({ | ||
type: 'APP/TOGGLE_DRAWER', | ||
payload | ||
}); | ||
expect(actions.toggleDrawer(error)).toEqual({ | ||
type: 'APP/TOGGLE_DRAWER', | ||
payload: error, | ||
error: true | ||
}); | ||
}); |
47 changes: 47 additions & 0 deletions
47
packages/venia-concept/src/actions/app/__tests__/asyncActions.spec.js
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,47 @@ | ||
import { dispatch, getState } from 'src/store'; | ||
import actions from '../actions'; | ||
import { closeDrawer, toggleDrawer } from '../asyncActions'; | ||
|
||
jest.mock('src/store'); | ||
|
||
const thunkArgs = [dispatch, getState]; | ||
|
||
afterEach(() => { | ||
dispatch.mockClear(); | ||
}); | ||
|
||
test('toggleDrawer() to return a thunk', () => { | ||
expect(toggleDrawer()).toBeInstanceOf(Function); | ||
}); | ||
|
||
test('toggleDrawer thunk returns undefined', async () => { | ||
const payload = 'FOO'; | ||
const result = await toggleDrawer(payload)(...thunkArgs); | ||
|
||
expect(result).toBeUndefined(); | ||
}); | ||
|
||
test('toggleDrawer thunk dispatches actions', async () => { | ||
const payload = 'FOO'; | ||
await toggleDrawer(payload)(...thunkArgs); | ||
|
||
expect(dispatch).toHaveBeenCalledWith(actions.toggleDrawer(payload)); | ||
expect(dispatch).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
test('closeDrawer() to return a thunk ', () => { | ||
expect(closeDrawer()).toBeInstanceOf(Function); | ||
}); | ||
|
||
test('closeDrawer thunk returns undefined', async () => { | ||
const result = await closeDrawer()(...thunkArgs); | ||
|
||
expect(result).toBeUndefined(); | ||
}); | ||
|
||
test('closeDrawer thunk dispatches actions', async () => { | ||
await closeDrawer()(...thunkArgs); | ||
|
||
expect(dispatch).toHaveBeenCalledWith(actions.toggleDrawer(null)); | ||
expect(dispatch).toHaveBeenCalledTimes(1); | ||
}); |
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,6 @@ | ||
import { createActions } from 'redux-actions'; | ||
|
||
const prefix = 'APP'; | ||
const actionTypes = ['TOGGLE_DRAWER']; | ||
|
||
export default createActions(...actionTypes, { prefix }); |
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,7 @@ | ||
import actions from './actions'; | ||
|
||
export const toggleDrawer = name => async dispatch => | ||
dispatch(actions.toggleDrawer(name)); | ||
|
||
export const closeDrawer = () => async dispatch => | ||
dispatch(actions.toggleDrawer(null)); |
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,2 @@ | ||
export { default } from './actions'; | ||
export * from './asyncActions'; |
Oops, something went wrong.