Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('renders top form', () => {
const props = {
name: 'Invoice workflow',
onNameChange: sinon.spy()
};
const wrapper = mount(, { context: { i18n: new I18nManager() } });
expect(wrapper).to.exist; // eslint-disable-line no-unused-expressions
expect(wrapper.contains(FormControl)).to.be.true; // eslint-disable-line no-unused-expressions
expect(wrapper.find(FormControl).prop('value')).to.equal(props.name);
expect(wrapper.find(FormControl).prop('onChange')).to.equal(props.onNameChange);
});
});
import React from 'react';
import { expect } from 'chai';
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-15';
import { mount } from 'enzyme';
import StatesTable from './StatesTable.react';
import { I18nManager } from '@opuscapita/i18n';
import messages from '../../i18n';
const i18n = new I18nManager();
i18n.register('asddass', messages);
Enzyme.configure({ adapter: new Adapter() });
describe('', () => {
it('renders a table of states', () => {
const props = {
states: [
{ name: 'one' },
{ name: 'two' }
],
initialState: 'one',
finalStates: ['two'],
onDelete: () => {},
onEdit: () => {},
statesInTransitions: []
import Adapter from 'enzyme-adapter-react-15';
import { mount } from 'enzyme';
import sinon from 'sinon';
import { I18nManager } from '@opuscapita/i18n';
import Tabs from 'react-bootstrap/lib/Tabs';
import Tab from 'react-bootstrap/lib/Tab';
import TabContent from 'react-bootstrap/lib/TabContent';
import WorkflowEditor from './WorkflowEditor.react';
import StatesTable from '../StatesTable';
import TransitionsTable from '../TransitionsTable';
import EditorOutput from '../EditorOutput.react';
import TopForm from '../TopForm.react';
Enzyme.configure({ adapter: new Adapter() });
const i18n = new I18nManager();
describe('', () => {
it('renders editor', () => {
const props = {
onSave: sinon.spy(),
workflow: {
schema: {
name: 'invoiceFlow',
initialState: 'open',
finalStates: ['approved', 'rejected'],
transitions: [
{
from: 'open',
to: 'validated',
event: 'validate'
},
getChildContext() {
if (!this.context.i18n) {
this.context.i18n = new I18nManager('en', null, formatPatterns);
}
return {
i18n: this.context.i18n,
serviceRegistry: serviceName => ({ url: 'http://localhost:3000' })
};
}
handleChangeLanguage = ({ target: { value } }) => this.setState({ locale: value }, _ => {
this.i18n = new I18nManager({ locale: value });
this.i18n.register(`${value}-${Math.random()}`, messages);
this.forceUpdate()
});
constructor(...args) {
super(...args);
this.i18n = new I18nManager();
this.i18n.register(`fsmWorkflowEditor`, messages);
}
constructor(...args) {
super(...args);
this.i18n = new I18nManager();
}
constructor(...args) {
super(...args);
this.i18n = new I18nManager();
}
validate(dateString, dateFormat) {
const i18nCompatibleFormat = dateFormat.replace(/D/g, 'd').replace(/Y/g, 'y');
const dc = new DateConverter(i18nCompatibleFormat);
try {
const date = dc.stringToValue(dateString);
const value = !dateString.length ? null : date;
this.props.onChange(value);
} catch (err) {
this.props.onError(err.message);
}
}