Skip to content

Commit

Permalink
chore: use element as key for entries
Browse files Browse the repository at this point in the history
  • Loading branch information
marstamm authored and philippfromme committed Aug 18, 2022
1 parent 6a033d1 commit 6075388
Show file tree
Hide file tree
Showing 14 changed files with 140 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/components/entries/Checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export default function CheckboxEntry(props) {
<Checkbox
disabled={ disabled }
id={ id }
key={ element }
label={ label }
onChange={ setValue }
value={ value } />
Expand Down
1 change: 1 addition & 0 deletions src/components/entries/FEEL/Feel.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ export default function FeelEntry(props) {
disabled={ disabled }
feel={ feel }
id={ id }
key={ element }
label={ label }
onInput={ onInput }
example={ props.example }
Expand Down
1 change: 1 addition & 0 deletions src/components/entries/NumberField.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export default function NumberFieldEntry(props) {
debounce={ debounce }
disabled={ disabled }
id={ id }
key={ element }
label={ label }
onInput={ setValue }
max={ max }
Expand Down
1 change: 1 addition & 0 deletions src/components/entries/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export default function SelectEntry(props) {
data-entry-id={ id }>
<Select
id={ id }
key={ element }
label={ label }
value={ value }
onChange={ setValue }
Expand Down
1 change: 1 addition & 0 deletions src/components/entries/Simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default function Simple(props) {
<div class="bio-properties-panel-simple">
<input
id={ prefixId(id) }
key={ element }
type="text"
name={ id }
spellCheck="false"
Expand Down
1 change: 1 addition & 0 deletions src/components/entries/TextArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export default function TextAreaEntry(props) {
data-entry-id={ id }>
<TextArea
id={ id }
key={ element }
label={ label }
value={ value }
onInput={ setValue }
Expand Down
1 change: 1 addition & 0 deletions src/components/entries/TextField.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export default function TextfieldEntry(props) {
debounce={ debounce }
disabled={ disabled }
id={ id }
key={ element }
label={ label }
onInput={ onInput }
value={ value } />
Expand Down
21 changes: 19 additions & 2 deletions test/spec/components/Checkbox.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,23 @@ describe('<Checkbox>', function() {
});


it('should use unique input element on element change', function() {

// given
const result = createCheckbox({ element: {}, container });

const input = domQuery('.bio-properties-panel-input', container);

// when
createCheckbox({ element: {}, container }, result.render);

// then
const newInput = domQuery('.bio-properties-panel-input', container);

expect(newInput).to.not.eql(input);
});


describe('#isEdited', function() {

it('should NOT be edited', function() {
Expand Down Expand Up @@ -282,7 +299,7 @@ describe('<Checkbox>', function() {

// helpers ////////////////////

function createCheckbox(options = {}) {
function createCheckbox(options = {}, renderFn = render) {
const {
element,
id,
Expand Down Expand Up @@ -315,7 +332,7 @@ function createCheckbox(options = {}) {
getDescriptionForId
};

return render(
return renderFn(
<ErrorsContext.Provider value={ errorsContext }>
<EventContext.Provider value={ eventContext }>
<PropertiesPanelContext.Provider value={ propertiesPanelContext }>
Expand Down
21 changes: 19 additions & 2 deletions test/spec/components/Feel.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,23 @@ describe('<FeelField>', function() {
});


it('should use unique input element on element change', function() {

// given
const result = createFeelField({ element: {}, container });

const input = domQuery('.bio-properties-panel-input', container);

// when
createFeelField({ element: {}, container }, result.render);

// then
const newInput = domQuery('.bio-properties-panel-input', container);

expect(newInput).to.not.eql(input);
});


describe('events', function() {

it('should show entry', function() {
Expand Down Expand Up @@ -1401,7 +1418,7 @@ function createFeelField(options = {}) {
}


function createFeelTextArea(options = {}) {
function createFeelTextArea(options = {}, renderFn = render) {
const {
element,
id,
Expand Down Expand Up @@ -1438,7 +1455,7 @@ function createFeelTextArea(options = {}) {
getDescriptionForId
};

return render(
return renderFn(
<ErrorsContext.Provider value={ errorsContext }>
<EventContext.Provider value={ eventContext }>
<PropertiesPanelContext.Provider value={ propertiesPanelContext }>
Expand Down
21 changes: 19 additions & 2 deletions test/spec/components/NumberField.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,23 @@ describe('<NumberField>', function() {
});


it('should use unique input element on element change', function() {

// given
const result = createNumberField({ element: {}, container });

const input = domQuery('.bio-properties-panel-input', container);

// when
createNumberField({ element: {}, container }, result.render);

// then
const newInput = domQuery('.bio-properties-panel-input', container);

expect(newInput).to.not.eql(input);
});


describe('#isEdited', function() {

it('should NOT be edited', function() {
Expand Down Expand Up @@ -315,7 +332,7 @@ describe('<NumberField>', function() {

// helpers ////////////////////

function createNumberField(options = {}) {
function createNumberField(options = {}, renderFn = render) {
const {
element,
debounce = fn => fn,
Expand All @@ -338,7 +355,7 @@ function createNumberField(options = {}) {
getDescriptionForId
};

return render(
return renderFn(
<DescriptionContext.Provider value={ context }>
<NumberField
element={ element }
Expand Down
21 changes: 19 additions & 2 deletions test/spec/components/Select.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,23 @@ describe('<Select>', function() {
});


it('should use unique input element on element change', function() {

// given
const result = createSelect({ element: {}, container });

const input = domQuery('.bio-properties-panel-input', container);

// when
createSelect({ element: {}, container }, result.render);

// then
const newInput = domQuery('.bio-properties-panel-input', container);

expect(newInput).to.not.eql(input);
});


describe('options', function() {

it('should render option enabled per default', function() {
Expand Down Expand Up @@ -364,7 +381,7 @@ describe('<Select>', function() {

// helpers ////////////////////

function createSelect(options = {}) {
function createSelect(options = {}, renderFn = render) {
const {
element,
id = 'select',
Expand Down Expand Up @@ -399,7 +416,7 @@ function createSelect(options = {}) {
getDescriptionForId
};

return render(
return renderFn(
<ErrorsContext.Provider value={ errorsContext }>
<EventContext.Provider value={ eventContext }>
<PropertiesPanelContext.Provider value={ propertiesPanelContext }>
Expand Down
21 changes: 19 additions & 2 deletions test/spec/components/Simple.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,23 @@ describe('<Simple>', function() {
});


it('should use unique input element on element change', function() {

// given
const result = createSimple({ element: {}, container });

const input = domQuery('.bio-properties-panel-input', container);

// when
createSimple({ element: {}, container }, result.render);

// then
const newInput = domQuery('.bio-properties-panel-input', container);

expect(newInput).to.not.eql(input);
});


it('should NOT blow up on empty value', function() {

// given
Expand Down Expand Up @@ -189,7 +206,7 @@ describe('<Simple>', function() {

// helpers ////////////////////

function createSimple(options = {}) {
function createSimple(options = {}, renderFn = render) {
const {
element,
id,
Expand All @@ -200,7 +217,7 @@ function createSimple(options = {}) {
container
} = options;

return render(
return renderFn(
<Simple
element={ element }
id={ id }
Expand Down
21 changes: 19 additions & 2 deletions test/spec/components/TextArea.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,23 @@ describe('<TextArea>', function() {
});


it('should use unique input element on element change', function() {

// given
const result = createTextArea({ element: {}, container });

const input = domQuery('.bio-properties-panel-input', container);

// when
createTextArea({ element: {}, container }, result.render);

// then
const newInput = domQuery('.bio-properties-panel-input', container);

expect(newInput).to.not.eql(input);
});


describe('events', function() {

it('should show entry', function() {
Expand Down Expand Up @@ -296,7 +313,7 @@ describe('<TextArea>', function() {

// helpers ////////////////////

function createTextArea(options = {}) {
function createTextArea(options = {}, renderFn = render) {
const {
element,
id,
Expand Down Expand Up @@ -333,7 +350,7 @@ function createTextArea(options = {}) {
getDescriptionForId
};

return render(
return renderFn(
<ErrorsContext.Provider value={ errorsContext }>
<EventContext.Provider value={ eventContext }>
<PropertiesPanelContext.Provider value={ propertiesPanelContext }>
Expand Down
21 changes: 19 additions & 2 deletions test/spec/components/TextField.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,23 @@ describe('<TextField>', function() {
});


it('should use unique input element on element change', function() {

// given
const result = createTextField({ element: {}, container });

const input = domQuery('.bio-properties-panel-input', container);

// when
createTextField({ element: {}, container }, result.render);

// then
const newInput = domQuery('.bio-properties-panel-input', container);

expect(newInput).to.not.eql(input);
});


describe('#isEdited', function() {

it('should NOT be edited', function() {
Expand Down Expand Up @@ -411,7 +428,7 @@ describe('<TextField>', function() {

// helpers ////////////////////

function createTextField(options = {}) {
function createTextField(options = {}, renderFn = render) {
const {
element,
id,
Expand Down Expand Up @@ -447,7 +464,7 @@ function createTextField(options = {}) {
getDescriptionForId
};

return render(
return renderFn(
<ErrorsContext.Provider value={ errorsContext }>
<EventContext.Provider value={ eventContext }>
<PropertiesPanelContext.Provider value={ propertiesPanelContext }>
Expand Down

0 comments on commit 6075388

Please sign in to comment.