react-redux-fetch
Version:
A declarative and customizable way to fetch data for React components and manage that data in the Redux state
74 lines (58 loc) • 2.5 kB
JavaScript
var _chai = require('chai');
var _chai2 = _interopRequireDefault(_chai);
var _seamlessImmutable = require('seamless-immutable');
var _seamlessImmutable2 = _interopRequireDefault(_seamlessImmutable);
var _selectors = require('./selectors');
var selectors = _interopRequireWildcard(_selectors);
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 }; }
_chai2.default.should();
describe('selectors', function () {
describe('getRepository', function () {
var state = (0, _seamlessImmutable2.default)({
repository: {
test: {
value: 123
}
}
});
it('should return a function', function () {
selectors.getRepository('test').should.be.a('function');
});
it('should return the repository from the state (curried version)', function () {
selectors.getRepository('test')(state).should.equal(123);
});
it('should have method \'fromState\'', function () {
selectors.getRepository('test').fromState.should.be.a('function');
});
it('should return the repository from the state (chained version)', function () {
selectors.getRepository('test').fromState(state).should.equal(123);
});
});
describe('getPromise', function () {
var state = (0, _seamlessImmutable2.default)({
repository: {
test: {
fulfilled: true,
pending: false,
value: 123
}
}
});
it('should return a function', function () {
selectors.getPromise('test').should.be.a('function');
});
it('should return the PromiseState from the state (curried version)', function () {
selectors.getPromise('test')(state).should.be.an('object');
selectors.getPromise('test')(state).should.equal(state.repository.test);
});
it('should have method \'fromState\'', function () {
selectors.getPromise('test').fromState.should.be.a('function');
});
it('should return the PromiseState from the state (chained version)', function () {
selectors.getPromise('test').fromState(state).should.be.an('object');
selectors.getPromise('test').fromState(state).should.equal(state.repository.test);
});
});
});
;