Skip to content
Commits on Source (3)
......@@ -2,6 +2,9 @@
import { configure, setAddon } from '@storybook/react'
import infoAddon, { setDefaults } from '@storybook/addon-info'
import { useStrict } from 'mobx'
useStrict(true)
// addon-info
setDefaults({
......
// import debug
import buildDebug from 'debug'
// prepare debug object
const debug = buildDebug('react-packages:__mocks__:rct-common-store')
// we generate an manualy mocked object
const rctCommonStore = jest.genMockFromModule('@4geit/rct-common-store')
// mocking members
rctCommonStore.token = '123467890'
rctCommonStore.user = {
_id: 0,
id: 'xxx-yyy-zzz',
email: 'aaaa@bbbb.xyz',
token: '123467890',
firstname: 'aaaa',
lastname: 'bbbb',
address: {
street: 'first street',
city: 'betterland',
state: 'poney',
postcode: '1234',
country: 'unicorn',
},
}
rctCommonStore.isLoggedIn = true
rctCommonStore.appLoaded = true
// mocking methods
rctCommonStore.setToken = async () => {
debug('setToken mocked!')
}
rctCommonStore.setAppLoaded = async () => {
debug('setAppLoaded mocked!')
}
rctCommonStore.logout = async () => {
debug('logout mocked!')
}
rctCommonStore.setUser = async () => {
debug('setUser mocked!')
}
rctCommonStore.restoreSession = async () => {
debug('restoreSession mocked!')
}
export default rctCommonStore
// import debug
import buildDebug from 'debug'
// prepare debug object
const debug = buildDebug('react-packages:__mocks__:rct-swagger-client-store')
// we generate an manualy mocked object
const rctSwaggerClientStore = jest.genMockFromModule('@4geit/rct-swagger-client-store')
// we mock the buildClient method behavior
// basically doing nothing
rctSwaggerClientStore.buildClient = function async () {
console.log('buildClient mocked!')
rctSwaggerClientStore.buildClient = async () => {
debug('buildClient mocked!')
}
// we do the same with buildClientWithToken
rctSwaggerClientStore.buildClientWithToken = function async () {
console.log('buildClientWithToken mocked!')
rctSwaggerClientStore.buildClientWithToken = async () => {
debug('buildClientWithToken mocked!')
}
// we do the same with buildClientWithAuthorizations
rctSwaggerClientStore.buildClientWithAuthorizations = function async () {
console.log('buildClientWithAuthorizations mocked!')
rctSwaggerClientStore.buildClientWithAuthorizations = async () => {
debug('buildClientWithAuthorizations mocked!')
}
// we mock the object of the `client` member and will mock also
......@@ -22,173 +26,217 @@ rctSwaggerClientStore.buildClientWithAuthorizations = function async () {
rctSwaggerClientStore.client = {
apis: {
Account: {
login: async function () {
console.log('login mocked')
login: async () => {
debug('login mocked')
},
register: async function () {
console.log('register mocked')
register: async () => {
debug('register mocked')
},
account: async function () {
console.log('account mocked')
account: async () => {
debug('account mocked')
return {
body: {
_id: 0,
id: 'xxx-yyy-zzz',
email: 'aaaa@bbbb.xyz',
token: '123467890',
firstname: 'aaaa',
lastname: 'bbbb',
address: {
street: 'first street',
city: 'betterland',
state: 'poney',
postcode: '1234',
country: 'unicorn',
},
}
}
},
contactList: async function () {
console.log('contactList mocked')
contactList: async () => {
debug('contactList mocked')
return {
body: []
}
},
contactAdd: async function () {
console.log('contactAdd mocked')
contactAdd: async () => {
debug('contactAdd mocked')
},
contactBulkAdd: async function () {
console.log('contactBulkAdd mocked')
contactBulkAdd: async () => {
debug('contactBulkAdd mocked')
},
contactGet: async function () {
console.log('contactGet mocked')
contactGet: async () => {
debug('contactGet mocked')
},
contactDelete: async function () {
console.log('contactDelete mocked')
contactDelete: async () => {
debug('contactDelete mocked')
},
contactUpdate: async function () {
console.log('contactUpdate mocked')
contactUpdate: async () => {
debug('contactUpdate mocked')
},
contactPopulate: async function () {
console.log('contactPopulate mocked')
contactPopulate: async () => {
debug('contactPopulate mocked')
},
productList: async function () {
console.log('productList mocked')
productList: async () => {
debug('productList mocked')
return {
body: []
}
},
productAdd: async function () {
console.log('productAdd mocked')
productAdd: async () => {
debug('productAdd mocked')
},
productBulkAdd: async function () {
console.log('productBulkAdd mocked')
productBulkAdd: async () => {
debug('productBulkAdd mocked')
},
productGet: async function () {
console.log('productGet mocked')
productGet: async () => {
debug('productGet mocked')
},
productDelete: async function () {
console.log('productDelete mocked')
productDelete: async () => {
debug('productDelete mocked')
},
productUpdate: async function () {
console.log('productUpdate mocked')
productUpdate: async () => {
debug('productUpdate mocked')
},
productPopulate: async function () {
console.log('productPopulate mocked')
productPopulate: async () => {
debug('productPopulate mocked')
},
chatboxList: async function () {
console.log('chatboxList mocked')
chatboxList: async () => {
debug('chatboxList mocked')
return {
body: []
}
},
chatboxAdd: async function () {
console.log('chatboxAdd mocked')
chatboxAdd: async () => {
debug('chatboxAdd mocked')
},
chatboxBulkAdd: async function () {
console.log('chatboxBulkAdd mocked')
chatboxBulkAdd: async () => {
debug('chatboxBulkAdd mocked')
},
chatboxGet: async function () {
console.log('chatboxGet mocked')
chatboxGet: async () => {
debug('chatboxGet mocked')
},
chatboxDelete: async function () {
console.log('chatboxDelete mocked')
chatboxDelete: async () => {
debug('chatboxDelete mocked')
},
chatboxUpdate: async function () {
console.log('chatboxUpdate mocked')
chatboxUpdate: async () => {
debug('chatboxUpdate mocked')
},
chatboxPopulate: async function () {
console.log('chatboxPopulate mocked')
chatboxPopulate: async () => {
debug('chatboxPopulate mocked')
},
chatboxStatusList: async function () {
console.log('chatboxStatusList mocked')
chatboxStatusList: async () => {
debug('chatboxStatusList mocked')
return {
body: []
}
},
userChatboxList: async function () {
console.log('userChatboxList mocked')
userChatboxList: async () => {
debug('userChatboxList mocked')
return {
body: []
}
},
userChatboxAdd: async function () {
console.log('userChatboxAdd mocked')
userChatboxAdd: async () => {
debug('userChatboxAdd mocked')
},
userChatboxBulkAdd: async function () {
console.log('userChatboxBulkAdd mocked')
userChatboxBulkAdd: async () => {
debug('userChatboxBulkAdd mocked')
},
userChatboxGet: async function () {
console.log('userChatboxGet mocked')
userChatboxGet: async () => {
debug('userChatboxGet mocked')
},
userChatboxDelete: async function () {
console.log('userChatboxDelete mocked')
userChatboxDelete: async () => {
debug('userChatboxDelete mocked')
},
userChatboxUpdate: async function () {
console.log('userChatboxUpdate mocked')
userChatboxUpdate: async () => {
debug('userChatboxUpdate mocked')
},
userChatboxPopulate: async function () {
console.log('userChatboxPopulate mocked')
userChatboxPopulate: async () => {
debug('userChatboxPopulate mocked')
},
eventList: async function () {
console.log('eventList mocked')
eventList: async () => {
debug('eventList mocked')
return {
body: []
}
},
timeslots: async function () {
console.log('timeslots mocked')
timeslots: async () => {
debug('timeslots mocked')
return {
body: []
}
},
messageList: async function () {
console.log('messageList mocked')
messageList: async () => {
debug('messageList mocked')
return {
body: []
}
},
messageAdd: async function () {
console.log('messageAdd mocked')
messageAdd: async () => {
debug('messageAdd mocked')
},
messageBulkAdd: async function () {
console.log('messageBulkAdd mocked')
messageBulkAdd: async () => {
debug('messageBulkAdd mocked')
},
messageGet: async function () {
console.log('messageGet mocked')
messageGet: async () => {
debug('messageGet mocked')
},
messageDelete: async function () {
console.log('messageDelete mocked')
messageDelete: async () => {
debug('messageDelete mocked')
},
messageUpdate: async function () {
console.log('messageUpdate mocked')
messageUpdate: async () => {
debug('messageUpdate mocked')
},
messagePopulate: async function () {
console.log('messagePopulate mocked')
messagePopulate: async () => {
debug('messagePopulate mocked')
},
notificationList: async function () {
console.log('notificationList mocked')
notificationList: async () => {
debug('notificationList mocked')
return {
body: []
}
},
notificationAdd: async function () {
console.log('notificationAdd mocked')
notificationAdd: async () => {
debug('notificationAdd mocked')
},
notificationBulkAdd: async function () {
console.log('notificationBulkAdd mocked')
notificationBulkAdd: async () => {
debug('notificationBulkAdd mocked')
},
notificationGet: async function () {
console.log('notificationGet mocked')
notificationGet: async () => {
debug('notificationGet mocked')
},
notificationDelete: async function () {
console.log('notificationDelete mocked')
notificationDelete: async () => {
debug('notificationDelete mocked')
},
notificationUpdate: async function () {
console.log('notificationUpdate mocked')
notificationUpdate: async () => {
debug('notificationUpdate mocked')
},
notificationPopulate: async function () {
console.log('notificationPopulate mocked')
notificationPopulate: async () => {
debug('notificationPopulate mocked')
},
todoList: async function () {
console.log('todoList mocked')
todoList: async () => {
debug('todoList mocked')
return {
body: []
}
},
todoAdd: async function () {
console.log('todoAdd mocked')
todoAdd: async () => {
debug('todoAdd mocked')
},
todoBulkAdd: async function () {
console.log('todoBulkAdd mocked')
todoBulkAdd: async () => {
debug('todoBulkAdd mocked')
},
todoGet: async function () {
console.log('todoGet mocked')
todoGet: async () => {
debug('todoGet mocked')
},
todoDelete: async function () {
console.log('todoDelete mocked')
todoDelete: async () => {
debug('todoDelete mocked')
},
todoUpdate: async function () {
console.log('todoUpdate mocked')
todoUpdate: async () => {
debug('todoUpdate mocked')
},
todoPopulate: async function () {
console.log('todoPopulate mocked')
todoPopulate: async () => {
debug('todoPopulate mocked')
},
}
}
......
{
"lerna": "2.0.0",
"version": "1.83.1",
"version": "1.83.2",
"npmClient": "yarn",
"useWorkspaces": true
}
......@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
<a name="1.83.2"></a>
## [1.83.2](https://gitlab.com/4geit/react-packages/compare/v1.83.1...v1.83.2) (2017-11-04)
**Note:** Version bump only for package @4geit/rct-account-component
<a name="1.83.1"></a>
## [1.83.1](https://gitlab.com/4geit/react-packages/compare/v1.83.0...v1.83.1) (2017-11-03)
......
{
"name": "@4geit/rct-account-component",
"version": "1.83.1",
"version": "1.83.2",
"description": "account component used as reusable package",
"main": "dist/index.js",
"src:module": "src/index.js",
......
......@@ -18,6 +18,30 @@ const stores = {
accountStore,
}
class ErrorBoundary extends Component {
constructor(props) {
super(props)
this.state = { hasError: false }
}
componentDidCatch(err, info) {
// display fallback UI
this.setState({ hasError: true })
}
render() {
if (this.state.hasError) {
// rendering custom fallback UI
return (
<h1>Something went wrong.</h1>
)
}
return (
this.props.children
)
}
}
@inject('swaggerClientStore', 'commonStore')
@observer
class App extends Component {
......@@ -60,7 +84,9 @@ storiesOf('RctAccountComponent', module)
<BrowserRouter>
<Provider { ...stores }>
<App>
<RctAccountComponent cardWidth='400px' />
<ErrorBoundary>
<RctAccountComponent cardWidth='400px' />
</ErrorBoundary>
</App>
</Provider>
</BrowserRouter>
......
......@@ -16,9 +16,9 @@ const stores = {
swaggerClientStore,
}
// initStoryshots({
// storyKindRegex: /^RctAccountComponent$/,
// })
initStoryshots({
storyKindRegex: /^RctAccountComponent$/,
})
it('renders without crashing', () => {
const div = document.createElement('div')
......
......@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
<a name="1.83.2"></a>
## [1.83.2](https://gitlab.com/4geit/react-packages/compare/v1.83.1...v1.83.2) (2017-11-04)
**Note:** Version bump only for package @4geit/rct-broadcast-message-component
<a name="1.83.1"></a>
## [1.83.1](https://gitlab.com/4geit/react-packages/compare/v1.83.0...v1.83.1) (2017-11-03)
......
{
"name": "@4geit/rct-broadcast-message-component",
"version": "1.83.1",
"version": "1.83.2",
"description": "Broadcast message component to display an input zone for typing and sending messages",
"main": "dist/index.js",
"src:module": "src/index.js",
......
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Storyshots RctBroadcastMessageComponent simple usage 1`] = `
<div>
<div>
<div
className="MuiPaper-root-2 MuiPaper-shadow2-6 MuiPaper-rounded-3"
>
<div
className="MuiCardContent-root-29"
>
<div
className="MuiGrid-typeContainer-30 MuiGrid-spacing-xs-16-50 MuiGrid-align-items-xs-center-36 MuiGrid-justify-xs-space-between-47"
>
<div
className="MuiGrid-typeItem-31 MuiGrid-grid-xs-11-64"
>
<form
className="withTheme-withWidth-inject-RctBroadcastMessageComponent-with-broadcastMessageStore-chatboxGridStore---form-1"
onSubmit={[Function]}
>
<div
className="MuiFormControl-root-118 MuiFormControl-marginNormal-119 MuiFormControl-fullWidth-121"
onBlur={[Function]}
onFocus={[Function]}
required={false}
>
<label
className="MuiFormLabel-root-128 MuiInputLabel-root-122 MuiInputLabel-formControl-123 MuiInputLabel-animated-126"
data-shrink={false}
htmlFor={undefined}
>
Your message
</label>
<div
className="MuiInput-root-132 MuiInput-formControl-133 MuiInput-inkbar-134 MuiInput-underline-140"
onBlur={[Function]}
onFocus={[Function]}
>
<input
autoComplete={undefined}
autoFocus={undefined}
className="MuiInput-input-136 MuiInput-inputSingleline-143"
defaultValue={undefined}
disabled={false}
id={undefined}
name={undefined}
onChange={[Function]}
onKeyDown={undefined}
onKeyUp={undefined}
placeholder={undefined}
readOnly={undefined}
required={undefined}
rows={undefined}
type="text"
value=""
/>
</div>
<p
className="MuiFormHelperText-root-147"
>
Send a message to all active chatboxes !
</p>
</div>
</form>
</div>
<div
className="MuiGrid-typeItem-31 MuiGrid-grid-xs-1-54"
>
<div
className="MuiGrid-typeContainer-30 MuiGrid-spacing-xs-16-50 MuiGrid-justify-xs-center-45"
>
<div
className="MuiGrid-typeItem-31"
>
<button
className="MuiButtonBase-root-165 MuiButton-root-151 MuiButton-raised-158 MuiButton-raisedPrimary-160 MuiButton-dense-152"
disabled={false}
onBlur={[Function]}
onFocus={[Function]}
onKeyDown={[Function]}
onKeyUp={[Function]}
onMouseDown={[Function]}
onMouseLeave={[Function]}
onMouseUp={[Function]}
onTouchEnd={[Function]}
onTouchMove={[Function]}
onTouchStart={[Function]}
role="button"
tabIndex={0}
type="submit"
>
<span
className="MuiButton-label-153"
>
Send
</span>
<span
className="MuiTouchRipple-root-167"
/>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
`;
exports[`renders correctly 1`] = `
<withTheme(withWidth(inject-RctBroadcastMessageComponent-with-broadcastMessageStore-chatboxGridStore))
classes={
......
......@@ -20,9 +20,9 @@ const stores = {
chatboxGridStore,
}
// initStoryshots({
// storyKindRegex: /^RctBroadcastMessageComponent$/,
// })
initStoryshots({
storyKindRegex: /^RctBroadcastMessageComponent$/,
})
it('renders without crashing', () => {
const div = document.createElement('div')
......
......@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
<a name="1.83.2"></a>
## [1.83.2](https://gitlab.com/4geit/react-packages/compare/v1.83.1...v1.83.2) (2017-11-04)
**Note:** Version bump only for package @4geit/rct-chatbox-grid-component
<a name="1.82.5"></a>
## [1.82.5](https://gitlab.com/4geit/react-packages/compare/v1.82.4...v1.82.5) (2017-11-02)
......
{
"name": "@4geit/rct-chatbox-grid-component",
"version": "1.82.5",
"version": "1.83.2",
"description": "chatbox grid component",
"main": "dist/index.js",
"src:module": "src/index.js",
......@@ -12,7 +12,7 @@
"author": "Fabian Starke <fabian@starke.fr>",
"license": "MIT",
"dependencies": {
"@4geit/rct-reorderable-grid-list-component": "^1.82.5",
"@4geit/rct-reorderable-grid-list-component": "^1.83.2",
"enzyme": "^3.x",
"material-ui": "next",
"material-ui-icons": "^1.0.0-beta.14",
......
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Storyshots RctChatboxGridComponent chatboxgrid with broadcast message component 1`] = `
<div>
<ul
className="MuiGridList-root-1"
style={
Object {
"margin": -2,
}
}
width="md"
/>
<div>
<div
className="MuiPaper-root-3 MuiPaper-shadow2-7 MuiPaper-rounded-4"
>
<div
className="MuiCardContent-root-30"
>
<div
className="MuiGrid-typeContainer-31 MuiGrid-spacing-xs-16-51 MuiGrid-align-items-xs-center-37 MuiGrid-justify-xs-space-between-48"
>
<div
className="MuiGrid-typeItem-32 MuiGrid-grid-xs-11-65"
>
<form
className="withTheme-withWidth-inject-RctBroadcastMessageComponent-with-broadcastMessageStore-chatboxGridStore---form-2"
onSubmit={[Function]}
>
<div
className="MuiFormControl-root-119 MuiFormControl-marginNormal-120 MuiFormControl-fullWidth-122"
onBlur={[Function]}
onFocus={[Function]}
required={false}
>
<label
className="MuiFormLabel-root-129 MuiInputLabel-root-123 MuiInputLabel-formControl-124 MuiInputLabel-animated-127"
data-shrink={false}
htmlFor={undefined}
>
Your message
</label>
<div
className="MuiInput-root-133 MuiInput-formControl-134 MuiInput-inkbar-135 MuiInput-underline-141"
onBlur={[Function]}
onFocus={[Function]}
>
<input
autoComplete={undefined}
autoFocus={undefined}
className="MuiInput-input-137 MuiInput-inputSingleline-144"
defaultValue={undefined}
disabled={false}
id={undefined}
name={undefined}
onChange={[Function]}
onKeyDown={undefined}
onKeyUp={undefined}
placeholder={undefined}
readOnly={undefined}
required={undefined}
rows={undefined}
type="text"
value=""
/>
</div>
<p
className="MuiFormHelperText-root-148"
>
Send a message to all active chatboxes!
</p>
</div>
</form>
</div>
<div
className="MuiGrid-typeItem-32 MuiGrid-grid-xs-1-55"
>
<div
className="MuiGrid-typeContainer-31 MuiGrid-spacing-xs-16-51 MuiGrid-justify-xs-center-46"
>
<div
className="MuiGrid-typeItem-32"
>
<button
className="MuiButtonBase-root-166 MuiButton-root-152 MuiButton-raised-159 MuiButton-raisedPrimary-161 MuiButton-dense-153"
disabled={false}
onBlur={[Function]}
onFocus={[Function]}
onKeyDown={[Function]}
onKeyUp={[Function]}
onMouseDown={[Function]}
onMouseLeave={[Function]}
onMouseUp={[Function]}
onTouchEnd={[Function]}
onTouchMove={[Function]}
onTouchStart={[Function]}
role="button"
tabIndex={0}
type="submit"
>
<span
className="MuiButton-label-154"
>
Send
</span>
<span
className="MuiTouchRipple-root-168"
/>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
`;
exports[`Storyshots RctChatboxGridComponent simple usage 1`] = `
<div>
<ul
className="MuiGridList-root-1"
style={
Object {
"margin": -2,
}
}
width="md"
/>
</div>
`;
exports[`renders correctly 1`] = `<withStyles(withTheme(withWidth(inject-RctChatboxGridComponent-with-chatboxGridStore))) />`;
import React from 'react'
import ReactDOM from 'react-dom'
import { inject, Provider } from 'mobx-react'
import { shallow } from 'enzyme'
import initStoryshots from '@storybook/addon-storyshots'
import commonStore from '@4geit/rct-common-store'
import swaggerClientStore from '@4geit/rct-swagger-client-store'
import chatboxGridStore from '@4geit/rct-chatbox-grid-store'
import broadcastMessageStore from '@4geit/rct-broadcast-message-store'
import RctChatboxGridComponent from './rct-chatbox-grid.component'
const stores = {
commonStore,
swaggerClientStore,
chatboxGridStore,
broadcastMessageStore,
}
initStoryshots({
storyKindRegex: /^RctChatboxGridComponent$/,
})
it('renders without crashing', () => {
const div = document.createElement('div')
ReactDOM.render(
<Provider { ...stores } >
<RctChatboxGridComponent />
</Provider>
, div)
})
it('renders correctly', () => {
const wrapper = shallow(
<Provider { ...stores } >
<RctChatboxGridComponent />
</Provider>
)
expect(wrapper).toMatchSnapshot()
})
......@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
<a name="1.83.2"></a>
## [1.83.2](https://gitlab.com/4geit/react-packages/compare/v1.83.1...v1.83.2) (2017-11-04)
**Note:** Version bump only for package @4geit/rct-chatbox-list-component
<a name="1.83.1"></a>
## [1.83.1](https://gitlab.com/4geit/react-packages/compare/v1.83.0...v1.83.1) (2017-11-03)
......
{
"name": "@4geit/rct-chatbox-list-component",
"version": "1.83.1",
"version": "1.83.2",
"description": "list chatbox items component",
"main": "dist/index.js",
"src:module": "src/index.js",
......
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Storyshots RctChatboxListComponent simple usage 1`] = `
<div
style={
Object {
"alignItems": "center",
"bottom": 0,
"display": "flex",
"justifyContent": "center",
"left": 0,
"overflow": "auto",
"position": "fixed",
"right": 0,
"top": 0,
}
}
>
<div
style={
Object {
"margin": "auto",
}
}
>
<div>
<ul
className="MuiList-root-2 MuiList-padding-3 MuiList-subheader-5 withTheme-withWidth-inject-RctChatboxListComponent-with-chatboxListStore---root-1"
>
<div
className="MuiListSubheader-root-6 MuiListSubheader-sticky-10"
>
Chatboxes
</div>
</ul>
</div>
</div>
</div>
`;
exports[`renders correctly 1`] = `<withStyles(withTheme(withWidth(inject-RctChatboxListComponent-with-chatboxListStore))) />`;