Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
39f97d9
feat(cmf): start to work on react-router v4
jmfrancois Mar 24, 2017
48b5ea8
fix: update and integrate react-router-redux v5 alpha
jmfrancois Mar 25, 2017
2e1d03b
style: fix lint
jmfrancois Mar 28, 2017
1119e1d
Merge branch 'master' into jmfrancois/update-react-router-v4
jmfrancois May 15, 2017
7a0a2ea
chore: add yarn
jmfrancois May 15, 2017
4943784
chore: big update
jmfrancois May 15, 2017
e0910b2
Merge branch 'master' into jmfrancois/update-react-router-v4
jsomsanith-tlnd May 19, 2017
7d2cae3
Merge branch 'master' into jmfrancois/update-react-router-v4
jsomsanith-tlnd May 22, 2017
4bb6f83
Merge branch 'master' into jmfrancois/update-react-router-v4
jmfrancois May 29, 2017
a257d57
Remove outdated file and same test twice
jsomsanith Jun 2, 2017
7f3f984
WIP JSO
jsomsanith Jun 2, 2017
72dc004
Merge branch 'master' into jmfrancois/update-react-router-v4
jsomsanith-tlnd Jun 5, 2017
44d1099
Fix tests and lint
jsomsanith Jun 14, 2017
11fd2b3
Merge branch 'master' into jmfrancois/update-react-router-v4
jsomsanith-tlnd Jun 14, 2017
92c49ba
Merge branch 'master' into jmfrancois/update-react-router-v4
jmfrancois Aug 11, 2017
68b0fe4
chore: upgrade to webpack 2
jmfrancois Aug 11, 2017
2a2d5c7
fix: update example
jmfrancois Aug 11, 2017
c7b946a
fix: align version which are working well together
jmfrancois Aug 11, 2017
fefa371
Merge branch 'master' into jmfrancois/update-react-router-v4
jmfrancois Aug 28, 2017
26a773a
chore: fix update from master + versions
jmfrancois Aug 28, 2017
40d78e8
fix: trigger re-render of the Router
jmfrancois Aug 29, 2017
22c0e03
Merge branch 'master' into jmfrancois/update-react-router-v4
jmfrancois Sep 12, 2017
49bc03d
Merge branch 'master' into jmfrancois/update-react-router-v4
acateland Nov 30, 2017
318865b
Merge branch 'master' into jmfrancois/update-react-router-v4
jmfrancois Jan 30, 2018
343d451
fix: remove example app
jmfrancois Jan 30, 2018
c6b409e
chore: re-add routing
jmfrancois Jan 31, 2018
c64cedd
chore: WIP
jmfrancois Jan 31, 2018
0c8f1d2
Merge master and fix tests
jsomsanith-tlnd Feb 20, 2018
978825d
Fix storybooks
jsomsanith-tlnd Feb 21, 2018
682e36b
feat: onEnter/onLeave
jsomsanith-tlnd Feb 23, 2018
d864daf
Add breaking changes log
jsomsanith-tlnd Feb 23, 2018
21036b9
Reorder router files
jsomsanith-tlnd Feb 23, 2018
7650d04
Split Router components
jsomsanith-tlnd Feb 23, 2018
eddb638
Refacto routes
jsomsanith-tlnd Feb 23, 2018
720ba91
Reorganise code and add doc
jsomsanith-tlnd Feb 23, 2018
2b7bbed
Rename UIRouter to CMFRouter and use componentDidXXX instead of compo…
jsomsanith-tlnd Feb 24, 2018
6d36b61
Fix tests and add on rout hook
jsomsanith-tlnd Feb 24, 2018
0cb15c1
Unit tests on CMFRoute
jsomsanith-tlnd Feb 24, 2018
846e2af
Unit test
jsomsanith-tlnd Feb 24, 2018
25a32e5
Update snapshots
jsomsanith-tlnd Feb 24, 2018
123f5aa
Merge master
jsomsanith-tlnd Mar 1, 2018
426ed8c
Merge master
jsomsanith-tlnd Mar 1, 2018
c6de172
Drawers
jsomsanith-tlnd Mar 2, 2018
226b0c4
Fix new component mount on every render :/
jsomsanith-tlnd Mar 3, 2018
69d94c0
feat: close animation within Drawer.Animation
jsomsanith-tlnd Mar 6, 2018
c7566a9
Add drawers unit tests
jsomsanith-tlnd Mar 6, 2018
6417c6a
Drawers clean and unit tests
jsomsanith-tlnd Mar 7, 2018
34af9cf
Merge master
jsomsanith-tlnd Mar 7, 2018
dba5d28
Document Drawers breaking changes
jsomsanith-tlnd Mar 7, 2018
94f299c
Update snapshots
jsomsanith-tlnd Mar 7, 2018
23a8fb3
Merge master
jsomsanith-tlnd Mar 17, 2018
e72d930
test(ci): update code style outputs
Mar 17, 2018
143d6d3
test(ci): prettier
Mar 17, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion output/cmf.eslint.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

The react/require-extension rule is deprecated. Please use the import/extensions rule from eslint-plugin-import instead.

/home/travis/build/Talend/ui/packages/cmf/src/App.js
20:1 error 'history' should be listed in the project's dependencies. Run 'npm i -S history' to add it import/no-extraneous-dependencies

/home/travis/build/Talend/ui/packages/cmf/src/componentState.js
88:3 warning Unexpected console statement no-console

Expand All @@ -21,5 +24,8 @@ The react/require-extension rule is deprecated. Please use the import/extensions
/home/travis/build/Talend/ui/packages/cmf/src/sagas/collection.js
10:1 error Prefer default export import/prefer-default-export

✖ 7 problems (3 errors, 4 warnings)
/home/travis/build/Talend/ui/packages/cmf/src/store.js
10:1 error 'history' should be listed in the project's dependencies. Run 'npm i -S history' to add it import/no-extraneous-dependencies

✖ 9 problems (5 errors, 4 warnings)

5 changes: 4 additions & 1 deletion output/components.eslint.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@ The react/require-extension rule is deprecated. Please use the import/extensions
/home/travis/build/Talend/ui/packages/components/src/VirtualizedList/utils/tablerow.js
33:3 warning Unexpected console statement no-console

✖ 11 problems (10 errors, 1 warning)
/home/travis/build/Talend/ui/packages/components/src/WithDrawer/withDrawer.test.js
5:8 error 'Drawer' is defined but never used no-unused-vars

✖ 12 problems (11 errors, 1 warning)

2 changes: 1 addition & 1 deletion output/components.sasslint.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


src/Drawer/Drawer.scss
14:4 warning Statement must begin on a new line brace-style
12:4 warning Statement must begin on a new line brace-style

src/FilterBar/FilterBar.scss
47:6 warning Vendor prefixes should not be used no-vendor-prefixes
Expand Down
8 changes: 4 additions & 4 deletions packages/cmf-cqrs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
"react": "^15.6.2",
"react-dom": "^15.6.2",
"react-redux": "5.0.5",
"react-router": "3.2.0",
"react-router-redux": "4.0.8",
"react-router": "4.2.0",
"react-router-redux": "5.0.0-alpha.9",
"react-test-renderer": "^15.6.2",
"redux": "3.6.0",
"redux-batched-actions": "0.2.0",
Expand All @@ -90,8 +90,8 @@
"react": "^15.6.2",
"react-dom": "^15.6.2",
"react-redux": "5.0.5",
"react-router": "3.2.0",
"react-router-redux": "4.0.8",
"react-router": "4.2.0",
"react-router-redux": "5.0.0-alpha.9",
"redux": "3.6.0",
"redux-batched-actions": "0.2.0",
"redux-storage": "^4.1.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/cmf/__tests__/App.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Provider } from 'react-redux';

import App from '../src/App';
import RegistryProvider from '../src/RegistryProvider';
import UIRouter from '../src/UIRouter';
import CMFRouter from '../src/route/CMFRouter';

describe('CMF App', () => {
it('App should init stuff', () => {
Expand All @@ -20,7 +20,7 @@ describe('CMF App', () => {
expect(wrapper.contains(
<Provider store={store}>
<RegistryProvider>
<UIRouter history={history} />
<CMFRouter history={history} />
</RegistryProvider>
</Provider>)
).toEqual(true);
Expand Down
22 changes: 0 additions & 22 deletions packages/cmf/__tests__/history.test.js

This file was deleted.

76 changes: 0 additions & 76 deletions packages/cmf/__tests__/route.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/* eslint no-underscore-dangle: ["error", {"allow": ["_registry", "_isLocked"] }] */
import React from 'react';
import { shallow } from 'enzyme';
import route from '../src/route';
import registry from '../src/registry';
import mock from '../src/mock';

describe('CMF route', () => {
it('registerComponent should be an alias to component.get', () => {
Expand All @@ -14,76 +11,3 @@ describe('CMF route', () => {
expect(emptyRegistry['_.route.component:C1']).toBe(C1);
});
});

describe('loadComponent behavior', () => {
it('should inject dispatch into component properties from context.store', () => {
const mockItem = {
component: 'component',
view: 'something',
};
route.loadComponents(mock.context(), mockItem);
const wrapper = shallow(React.createElement(mockItem.component), { context: mock.context() });
expect(wrapper.props().dispatch()).toBe('dispatch');
});

it('should replace component by regitry one', () => {
const mockItem = {
component: 'TestContainer',
view: 'appmenu',
};
const obj = { fn: jest.fn() };
const component = obj.fn;
component.CMFContainer = true;
const mockContext = mock.context();
mockContext.registry = {
'_.route.component:TestContainer': component,
};
route.loadComponents(mockContext, mockItem);
component();
expect(obj.fn).toHaveBeenCalled();
expect(mockItem.component.displayName).toBe('WithView');
});

it('should replace onEnter/onLeave hooks', () => {
// given
const mockItem = {
component: 'TestContainer',
view: 'appmenu',
onEnter: 'onEnterId',
onLeave: 'onLeaveId',
};
const dispatch = jest.fn();
const component = jest.fn();
component.CMFContainer = true;
const onEnter = jest.fn();
const onLeave = jest.fn();
const nextState = { params: {} };
const replace = jest.fn();

const mockContext = mock.context();
mockContext.registry = {
'_.route.hook:onEnterId': onEnter,
'_.route.hook:onLeaveId': onLeave,
'_.route.component:TestContainer': component,
};

// when
route.loadComponents(mockContext, mockItem, dispatch);


// then
expect(onEnter).not.toBeCalled();
mockItem.onEnter(nextState, replace);
expect(onEnter).toBeCalledWith({
router: { nextState, replace },
dispatch,
});

expect(onLeave).not.toBeCalled();
mockItem.onLeave(nextState, replace);
expect(onLeave).toBeCalledWith({
router: { nextState, replace },
dispatch,
});
});
});
87 changes: 87 additions & 0 deletions packages/cmf/__tests__/route/CMFRoute.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import React from 'react';
import PropTypes from 'prop-types';
import { shallow } from 'enzyme';
import CMFRoute from '../../src/route/CMFRoute';

const routes = {
path: '/',
component: 'App',
indexRoute: {
component: 'Redirect',
view: 'indexRouteRedirect',
},
childRoutes: [
{
path: 'preparations/:folderId?',
component: 'HomeListView',
view: 'preparations',
onEnter: 'preparation:fetch',
},
{
path: 'datasets',
component: 'HomeListView',
view: 'datasets',
},
{
path: 'datastores',
component: 'HomeListView',
view: 'datastores',
},
],
};

const App = props => (<div>{props.children}</div>);
App.propTypes = { children: PropTypes.element };
const HomeListView = props => (<div>{props.children}</div>);
HomeListView.propTypes = { children: PropTypes.element };
const Redirect = () => (<div />);
function createContext() {
return {
registry: {
'_.route.component:App': App,
'_.route.component:HomeListView': HomeListView,
'_.route.component:Redirect': Redirect,
},
};
}

describe('CMFRoute', () => {
it('should instantiate Route component', () => {
// given
const context = createContext();

// when
const wrapper = shallow(
(
<CMFRoute {...routes}>
<div />
</CMFRoute>
),
{ context },
);

// then
expect(wrapper.getElement()).toMatchSnapshot();
});

it('should instantiate nested Route component', () => {
// given
const context = createContext();
const match = { params: {}, url: '/', path: '/' };

// when
const wrapper = shallow(
(
<CMFRoute {...routes}>
<div />
</CMFRoute>
),
{ context },
);
const Component = wrapper.props().component;
const componentWrapper = shallow(<Component match={match} />);

// then
expect(componentWrapper.getElement()).toMatchSnapshot();
});
});
119 changes: 119 additions & 0 deletions packages/cmf/__tests__/route/CMFRouteHook.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import React from 'react';
import { shallow } from 'enzyme';
import { CMFRouteHookComponent } from '../../src/route/CMFRouteHook';

const onEnter = 'myComponent:onEnter';
const onLeave = 'myComponent:onLeave';
function createContext(onEnterFn, onLeaveFn) {
return {
registry: {
[`_.route.hook:${onEnter}`]: onEnterFn,
[`_.route.hook:${onLeave}`]: onLeaveFn,
},
};
}

describe('CMFRouteHook', () => {
it('should render its children', () => {
// given
const MyComponent = () => (<div>My component</div>);

// when
const wrapper = shallow(
<CMFRouteHookComponent>
<MyComponent />
</CMFRouteHookComponent>
);

// then
expect(wrapper.getElement()).toMatchSnapshot();
});

it('should create onEnter/onLeave function', () => {
// given
const onEnterFn = jest.fn();
const onLeaveFn = jest.fn();
const context = createContext(onEnterFn, onLeaveFn);

// when
const wrapper = shallow(
(
<CMFRouteHookComponent
dispatch={jest.fn()}
onEnter={onEnter}
onLeave={onLeave}
>
<div />
</CMFRouteHookComponent>
),
{ context },
);

// then
expect(wrapper.instance().onEnter).toBe(onEnterFn);
expect(wrapper.instance().onLeave).toBe(onLeaveFn);
});

it('should call onEnter when componentDidMount', () => {
// given
const onEnterFn = jest.fn();
const onLeaveFn = jest.fn();
const context = createContext(onEnterFn, onLeaveFn);
const dispatch = jest.fn();
const match = { params: {} };

// when
shallow(
(
<CMFRouteHookComponent
dispatch={dispatch}
onEnter={onEnter}
onLeave={onLeave}
match={match}
>
<div />
</CMFRouteHookComponent>
),
{ context },
);

// then
expect(onEnterFn).toBeCalledWith({
router: { match },
dispatch,
});
});

it('should call onLeave when componentWillUnmount', () => {
// given
const onEnterFn = jest.fn();
const onLeaveFn = jest.fn();
const context = createContext(onEnterFn, onLeaveFn);
const dispatch = jest.fn();
const match = { params: {} };

const wrapper = shallow(
(
<CMFRouteHookComponent
dispatch={dispatch}
onEnter={onEnter}
onLeave={onLeave}
match={match}
>
<div />
</CMFRouteHookComponent>
),
{ context },
);
expect(onLeaveFn).not.toBeCalled();

// when
wrapper.unmount();

// then
expect(onLeaveFn).toBeCalledWith({
router: { match },
dispatch,
});
});
});
Loading