-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
1,280 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.Component = exports.key = exports.reducer = exports.actions = exports.actionTypes = undefined; | ||
|
||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
|
||
var _redux = require('redux'); | ||
|
||
var _reactRedux = require('react-redux'); | ||
|
||
var _Snackbar = require('material-ui/Snackbar'); | ||
|
||
var _Snackbar2 = _interopRequireDefault(_Snackbar); | ||
|
||
var _actions = require('./flash/actions'); | ||
|
||
var actions = _interopRequireWildcard(_actions); | ||
|
||
var _actionTypes = require('./flash/actionTypes'); | ||
|
||
var actionTypes = _interopRequireWildcard(_actionTypes); | ||
|
||
var _reducer = require('./flash/reducer'); | ||
|
||
var _reducer2 = _interopRequireDefault(_reducer); | ||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
var NAME = 'flash'; | ||
|
||
var mapStateToProps = function mapStateToProps(_ref) { | ||
var props = _ref[NAME]; | ||
return _extends({}, props); | ||
}; | ||
|
||
var mapDispatchToProps = function mapDispatchToProps(dispatch) { | ||
return { | ||
onRequestClose: (0, _redux.bindActionCreators)(actions.hide, dispatch) | ||
}; | ||
}; | ||
|
||
var Component = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(_Snackbar2.default); | ||
|
||
exports.actionTypes = actionTypes; | ||
exports.actions = actions; | ||
exports.reducer = _reducer2.default; | ||
exports.key = NAME; | ||
exports.Component = Component; | ||
exports.default = { | ||
actionTypes: actionTypes, | ||
actions: actions, | ||
reducer: _reducer2.default, | ||
key: NAME, | ||
Component: Component | ||
}; |
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,66 @@ | ||
'use strict'; | ||
|
||
var _reduxMockStore = require('redux-mock-store'); | ||
|
||
var _reduxMockStore2 = _interopRequireDefault(_reduxMockStore); | ||
|
||
var _reduxThunk = require('redux-thunk'); | ||
|
||
var _reduxThunk2 = _interopRequireDefault(_reduxThunk); | ||
|
||
var _actions = require('../actions'); | ||
|
||
var _actionTypes = require('../actionTypes'); | ||
|
||
var actionTypes = _interopRequireWildcard(_actionTypes); | ||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
var mockStore = (0, _reduxMockStore2.default)([_reduxThunk2.default]); | ||
|
||
describe('show', function () { | ||
it('dispatches a single action', function () { | ||
var store = mockStore({}); | ||
store.dispatch((0, _actions.show)('Hello World')); | ||
expect(store.getActions().length).toEqual(1); | ||
}); | ||
|
||
it('dispatches FLASH/SHOW right away', function () { | ||
var store = mockStore({}); | ||
store.dispatch((0, _actions.show)('Hello World')); | ||
expect(store.getActions()[0].type).toEqual(actionTypes.SHOW_FLASH); | ||
}); | ||
|
||
it('includes the message and given props in the action payload', function () { | ||
var store = mockStore({}); | ||
store.dispatch((0, _actions.show)('Hello World', { edit: 1 })); | ||
expect(store.getActions()[0]).toMatchObject({ | ||
type: actionTypes.SHOW_FLASH, | ||
message: 'Hello World', | ||
edit: 1 | ||
}); | ||
}); | ||
|
||
it('includes extra props in the action payload', function () { | ||
var store = mockStore({}); | ||
store.dispatch((0, _actions.show)('Hello World')); | ||
expect(store.getActions()[0]).toMatchObject({ | ||
type: actionTypes.SHOW_FLASH, | ||
autoHideDuration: 5000 | ||
}); | ||
}); | ||
|
||
it('allows to override the default autoHideDuration', function () { | ||
var store = mockStore({}); | ||
store.dispatch((0, _actions.show)('Hello World', { autoHideDuration: 1000 })); | ||
expect(store.getActions()[0].autoHideDuration).toEqual(1000); | ||
}); | ||
|
||
it('does not allow to override the message with props', function () { | ||
var store = mockStore({}); | ||
store.dispatch((0, _actions.show)('Hello World', { message: 'Goodbye' })); | ||
expect(store.getActions()[0].message).toEqual('Hello World'); | ||
}); | ||
}); |
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,50 @@ | ||
'use strict'; | ||
|
||
var _actionTypes = require('../actionTypes'); | ||
|
||
var _reducer = require('../reducer'); | ||
|
||
var _reducer2 = _interopRequireDefault(_reducer); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
describe(_actionTypes.SHOW_FLASH, function () { | ||
it('sets open to true', function () { | ||
expect((0, _reducer2.default)({ open: false }, { type: _actionTypes.SHOW_FLASH })).toEqual({ | ||
open: true | ||
}); | ||
expect((0, _reducer2.default)({ open: true }, { type: _actionTypes.SHOW_FLASH })).toEqual({ | ||
open: true | ||
}); | ||
}); | ||
|
||
it('injects any extra props in the state', function () { | ||
expect((0, _reducer2.default)({ open: false }, { type: _actionTypes.SHOW_FLASH, custom: 1 })).toEqual({ | ||
open: true, | ||
custom: 1 | ||
}); | ||
}); | ||
|
||
it('does not allow to set the open value via extra props', function () { | ||
expect((0, _reducer2.default)({ open: false }, { type: _actionTypes.SHOW_FLASH, custom: 1, open: 'Yes' })).toEqual({ open: true, custom: 1 }); | ||
}); | ||
|
||
it('clears any previous props in the state', function () { | ||
expect((0, _reducer2.default)({ open: false, message: 'Hello' }, { type: _actionTypes.SHOW_FLASH, message: 'Goodbye' })).toEqual({ open: true, message: 'Goodbye' }); | ||
}); | ||
}); | ||
|
||
describe(_actionTypes.HIDE_FLASH, function () { | ||
it('sets open to false', function () { | ||
expect((0, _reducer2.default)({ open: false }, { type: _actionTypes.HIDE_FLASH })).toEqual({ | ||
open: false | ||
}); | ||
expect((0, _reducer2.default)({ open: true }, { type: _actionTypes.HIDE_FLASH })).toEqual({ | ||
open: false | ||
}); | ||
}); | ||
|
||
it('keeps anything else in the state intact', function () { | ||
expect((0, _reducer2.default)({ open: true, message: 'Hello', custom: 1 }, { type: _actionTypes.HIDE_FLASH })).toEqual({ open: false, message: 'Hello', custom: 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,7 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var SHOW_FLASH = exports.SHOW_FLASH = 'FLASH/SHOW'; | ||
var HIDE_FLASH = exports.HIDE_FLASH = 'FLASH/HIDE'; |
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,30 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.hide = exports.show = undefined; | ||
|
||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
|
||
var _actionTypes = require('./actionTypes'); | ||
|
||
var actionTypes = _interopRequireWildcard(_actionTypes); | ||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
|
||
var show = exports.show = function show(message) { | ||
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
return _extends({ | ||
type: actionTypes.SHOW_FLASH, | ||
autoHideDuration: 5000 | ||
}, props, { | ||
message: message | ||
}); | ||
}; | ||
|
||
var hide = exports.hide = function hide() { | ||
return { | ||
type: actionTypes.HIDE_FLASH | ||
}; | ||
}; |
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,33 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
|
||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
|
||
var _actionTypes = require('./actionTypes'); | ||
|
||
var actionTypes = _interopRequireWildcard(_actionTypes); | ||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
|
||
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | ||
|
||
exports.default = function () { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { open: false }; | ||
|
||
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
|
||
var type = _ref.type, | ||
props = _objectWithoutProperties(_ref, ['type']); | ||
|
||
switch (type) { | ||
case actionTypes.SHOW_FLASH: | ||
return _extends({}, props, { open: true }); | ||
case actionTypes.HIDE_FLASH: | ||
return _extends({}, state, { open: false }); | ||
default: | ||
return state; | ||
} | ||
}; |
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,64 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.Component = exports.key = exports.reducer = exports.actions = exports.actionTypes = undefined; | ||
|
||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
|
||
var _redux = require('redux'); | ||
|
||
var _reactRedux = require('react-redux'); | ||
|
||
var _Modal = require('./modal/Modal'); | ||
|
||
var _Modal2 = _interopRequireDefault(_Modal); | ||
|
||
var _actions = require('./modal/actions'); | ||
|
||
var actions = _interopRequireWildcard(_actions); | ||
|
||
var _actionTypes = require('./modal/actionTypes'); | ||
|
||
var actionTypes = _interopRequireWildcard(_actionTypes); | ||
|
||
var _reducer = require('./modal/reducer'); | ||
|
||
var _reducer2 = _interopRequireDefault(_reducer); | ||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
var NAME = 'modal'; | ||
|
||
var mapStateToProps = function mapStateToProps(_ref) { | ||
var _ref$NAME = _ref[NAME], | ||
component = _ref$NAME.component, | ||
props = _ref$NAME.props; | ||
return _extends({}, props, { | ||
component: component | ||
}); | ||
}; | ||
|
||
var mapDispatchToProps = function mapDispatchToProps(dispatch) { | ||
return { | ||
hide: (0, _redux.bindActionCreators)(actions.hideModal, dispatch) | ||
}; | ||
}; | ||
|
||
var Component = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(_Modal2.default); | ||
|
||
exports.actionTypes = actionTypes; | ||
exports.actions = actions; | ||
exports.reducer = _reducer2.default; | ||
exports.key = NAME; | ||
exports.Component = Component; | ||
exports.default = { | ||
actionTypes: actionTypes, | ||
actions: actions, | ||
reducer: _reducer2.default, | ||
key: NAME, | ||
Component: Component | ||
}; |
Oops, something went wrong.