forked from Gitlink/forgeplus-react
40 lines
1.9 KiB
JavaScript
40 lines
1.9 KiB
JavaScript
'use strict';
|
|
|
|
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
|
|
|
|
var _urlQueryConfig = require('../urlQueryConfig');
|
|
|
|
var _urlQueryConfig2 = _interopRequireDefault(_urlQueryConfig);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
it('provides defaults for all options', function () {
|
|
expect(Object.keys(_urlQueryConfig2.default)).toContain('addUrlChangeHandlers');
|
|
expect(Object.keys(_urlQueryConfig2.default)).toContain('addRouterParams');
|
|
expect(Object.keys(_urlQueryConfig2.default)).toContain('changeHandlerName');
|
|
expect(Object.keys(_urlQueryConfig2.default)).toContain('history');
|
|
expect(Object.keys(_urlQueryConfig2.default)).toContain('readLocationFromStore');
|
|
});
|
|
|
|
it('changeHandlerName produces a string based on the prop name', function () {
|
|
expect(_urlQueryConfig2.default.changeHandlerName('foo').toLowerCase()).toContain('foo');
|
|
});
|
|
|
|
it('provides a history with push and replace functions', function () {
|
|
expect(_typeof(_urlQueryConfig2.default.history.push)).toBe('function');
|
|
expect(_typeof(_urlQueryConfig2.default.history.replace)).toBe('function');
|
|
});
|
|
|
|
it('provides readLocationFromStore that reads from react-router-redux location', function () {
|
|
expect(_typeof(_urlQueryConfig2.default.readLocationFromStore)).toBe('function');
|
|
var reactRouterReduxState = {
|
|
routing: { locationBeforeTransitions: { foo: 'bar' } }
|
|
};
|
|
expect(_urlQueryConfig2.default.readLocationFromStore(reactRouterReduxState)).toEqual({
|
|
foo: 'bar'
|
|
});
|
|
|
|
expect(_urlQueryConfig2.default.readLocationFromStore()).not.toBeDefined();
|
|
expect(_urlQueryConfig2.default.readLocationFromStore({})).not.toBeDefined();
|
|
expect(_urlQueryConfig2.default.readLocationFromStore({ routing: {} })).not.toBeDefined();
|
|
}); |