Skip to content

Commit

Permalink
Merge branch 'next'
Browse files Browse the repository at this point in the history
  • Loading branch information
foxhound87 committed Mar 28, 2023
2 parents 30a87cc + 389905d commit e7aaad2
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 5.5.2 (next)

- Fix: Empty Constructor (was requiring at least an empyt object if used with only class fileds definitions)

# 5.5.1 (next)

- Introduced `preserveDeletedFieldsValues` form option (disabled by default).
Expand Down
2 changes: 1 addition & 1 deletion src/Form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class Form extends Base implements FormInterface {
debouncedValidation: any = null;

constructor(
setup: FieldsDefinitions,
setup: FieldsDefinitions = {},
{
name = "",
options = {},
Expand Down
2 changes: 1 addition & 1 deletion src/State.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default class State implements StateInterface {
this.observeOptions();
}

initProps(initial: any) {
initProps(initial: any = {}) {
const initialProps: any = _.pick(initial, [
...props.separated,
...props.validation,
Expand Down
3 changes: 3 additions & 0 deletions tests/data/_.fixes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
FIXES
*/
import $formEmptyConstructor from "./forms/form.empty.constructor";

import $A from "./forms/fixes/form.a";
import $B from "./forms/fixes/form.b";
import $C from "./forms/fixes/form.c";
Expand Down Expand Up @@ -42,6 +44,7 @@ import $585 from "./forms/fixes/form.585";
import $531 from "./forms/fixes/form.531";

export default {
$formEmptyConstructor,
$A,
$B,
$C,
Expand Down
4 changes: 4 additions & 0 deletions tests/data/forms/form.empty.constructor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import MobxReactForm from "../../../src";

// EMPTY CONSTRUCTOR
export default new MobxReactForm(); // do not change!
5 changes: 5 additions & 0 deletions tests/fixes.props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import { expect } from 'chai';

import $ from './data/_.fixes'; // FORMS

describe('Check Fixes $E props check', () => {
it('$formEmptyConstrcutor size should be equal 0', () =>
expect($.$formEmptyConstructor.size).to.be.equal(0));
});


describe('Check Fixes $E props check', () => {
it('$E places extra should be array', () =>
Expand Down

0 comments on commit e7aaad2

Please sign in to comment.