Skip to content

Commit ef92be1

Browse files
Merge pull request #13 from SimplrJS/hotfix/core
Jest dependency on react addons removed. FormStoreHandlerClass -> FormStoreHandler.
2 parents 25f509b + 2d62c4d commit ef92be1

File tree

6 files changed

+36
-35
lines changed

6 files changed

+36
-35
lines changed

packages/simplr-forms-core/__tests__/abstractions/base-field.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ import * as ReactDOM from "react-dom";
33
import { shallow, mount } from "enzyme";
44
import { spy } from "sinon";
55

6-
import { FormStoresHandlerClass, FSHContainer } from "../../src/stores/form-stores-handler";
6+
import { FormStoresHandler, FSHContainer } from "../../src/stores/form-stores-handler";
77
import { FormStore } from "../../src/stores/form-store";
88
import { MyTestForm } from "../test-components/test-form";
99
import { MyTestField, MyFieldProps } from "../test-components/test-field";
1010
import { FormChildContext } from "../../src/contracts/form";
1111

1212
describe("Field Base", () => {
1313
beforeEach(() => {
14-
FSHContainer.SetFormStoresHandler(new FormStoresHandlerClass(), true);
14+
FSHContainer.SetFormStoresHandler(new FormStoresHandler(), true);
1515
});
1616

1717
it("works", () => {

packages/simplr-forms-core/__tests__/abstractions/base-form.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import * as React from "react";
22
import { shallow, mount } from "enzyme";
33

4-
import { FSHContainer, FormStoresHandlerClass } from "../../src/stores/form-stores-handler";
4+
import { FSHContainer, FormStoresHandler } from "../../src/stores/form-stores-handler";
55
import { MyTestForm } from "../test-components/test-form";
66

77
describe("Form base", () => {
88
beforeEach(() => {
9-
FSHContainer.SetFormStoresHandler(new FormStoresHandlerClass(), true);
9+
FSHContainer.SetFormStoresHandler(new FormStoresHandler(), true);
1010
});
1111

1212
describe("registers when", () => {

packages/simplr-forms-core/__tests__/stores/form-stores-handler.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { FSHContainer, FormStoresHandlerClass } from "../../src/stores/form-stores-handler";
2-
import * as Actions from "../../src/actions/form-stores-handler-actions";
1+
import { FSHContainer, FormStoresHandler } from "../../src/stores/form-stores-handler";
2+
import * as Actions from "../../src/actions/form-stores-handler";
33
import * as sinon from "Sinon";
44

55
describe("Form stores handler", () => {
66
it("returns next store unique formId", () => {
7-
let storesHandler = new FormStoresHandlerClass();
7+
let storesHandler = new FormStoresHandler();
88
let a = storesHandler.NextStoreId();
99
let b = storesHandler.NextStoreId();
1010

@@ -14,7 +14,7 @@ describe("Form stores handler", () => {
1414
});
1515

1616
it("returns count of currently registered stores", () => {
17-
let storesHandler = new FormStoresHandlerClass();
17+
let storesHandler = new FormStoresHandler();
1818
let id = storesHandler.NextStoreId();
1919
let id2 = storesHandler.NextStoreId();
2020

@@ -29,7 +29,7 @@ describe("Form stores handler", () => {
2929
});
3030

3131
it("registers and gets generated formId", () => {
32-
let storesHandler = new FormStoresHandlerClass();
32+
let storesHandler = new FormStoresHandler();
3333
let generatedFormId = storesHandler.RegisterForm();
3434

3535
expect(generatedFormId).toBeTruthy();
@@ -38,7 +38,7 @@ describe("Form stores handler", () => {
3838
});
3939

4040
it("registers with custom formId", () => {
41-
let storesHandler = new FormStoresHandlerClass();
41+
let storesHandler = new FormStoresHandler();
4242
const FORM_ID = "custom-form-id";
4343

4444
expect(storesHandler.RegisterForm(FORM_ID)).toBe(FORM_ID);
@@ -56,13 +56,13 @@ describe("Form stores handler", () => {
5656
expect(storesHandler.StoresCount).toBe(1);
5757
expect(storesHandler.Exists(FORM_ID)).toBe(true);
5858

59-
FSHContainer.SetFormStoresHandler(new FormStoresHandlerClass(), true);
59+
FSHContainer.SetFormStoresHandler(new FormStoresHandler(), true);
6060

6161
expect(storesHandler.StoresCount).toBe(0);
6262
});
6363

6464
it("returns true if form store exists", () => {
65-
let storesHandler = new FormStoresHandlerClass();
65+
let storesHandler = new FormStoresHandler();
6666
const FORM_ID = "custom-form-id";
6767
const ANOTHER_FORM_ID = "another-custom-form-id";
6868
storesHandler.RegisterForm(FORM_ID);
@@ -72,7 +72,7 @@ describe("Form stores handler", () => {
7272
});
7373

7474
it("registers and unregisters form", () => {
75-
let storesHandler = new FormStoresHandlerClass();
75+
let storesHandler = new FormStoresHandler();
7676
let generatedFormId = storesHandler.RegisterForm();
7777

7878
expect(storesHandler.Exists(generatedFormId)).toBe(true);
@@ -81,14 +81,14 @@ describe("Form stores handler", () => {
8181
});
8282

8383
it("returns store", () => {
84-
let storesHandler = new FormStoresHandlerClass();
84+
let storesHandler = new FormStoresHandler();
8585
let generatedFormId = storesHandler.RegisterForm();
8686

8787
expect(storesHandler.GetStore(generatedFormId)).toBeTruthy();
8888
});
8989

9090
it("emits register action when registering a new form", () => {
91-
const storesHandler = new FormStoresHandlerClass();
91+
const storesHandler = new FormStoresHandler();
9292
const callbackSpy = sinon.spy();
9393

9494
storesHandler.addListener(Actions.FormRegistered, callbackSpy);
@@ -98,7 +98,7 @@ describe("Form stores handler", () => {
9898
});
9999

100100
it("emits unregister action when unregistering a form", () => {
101-
const storesHandler = new FormStoresHandlerClass();
101+
const storesHandler = new FormStoresHandler();
102102
const formId = "form-id";
103103
const callbackSpy = sinon.spy();
104104

packages/simplr-forms-core/package.json

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,32 @@
1818
"author": "simplrjs <[email protected]> (https://github.com/simplrjs)",
1919
"license": "AGPL-3.0",
2020
"devDependencies": {
21-
"@types/enzyme": "^2.7.7",
21+
"@types/enzyme": "^2.7.9",
2222
"@types/jest": "^19.2.2",
2323
"@types/sinon": "^2.1.2",
24-
"enzyme": "^2.8.0",
24+
"enzyme": "^2.8.2",
2525
"jest": "^19.0.2",
26-
"jest-enzyme": "^3.0.0",
27-
"react-addons-test-utils": "^15.5.1",
26+
"jest-enzyme": "^3.0.1",
27+
"react-dom": "^15.5.4",
28+
"react-test-renderer": "^15.5.4",
2829
"sinon": "^2.1.0",
29-
"ts-jest": "^19.0.8",
30+
"ts-jest": "^19.0.10",
3031
"ts-loader": "^2.0.3",
31-
"tslint": "^5.0.0",
32+
"tslint": "^5.1.0",
3233
"typescript": "2.3.0",
3334
"uglify-js": "^2.8.22",
34-
"webpack": "^2.3.3"
35+
"webpack": "^2.4.1"
3536
},
3637
"dependencies": {
3738
"@types/fbemitter": "^2.0.32",
3839
"@types/flux": "^3.0.1",
39-
"@types/react": "^15.0.21",
40-
"@types/react-dom": "^0.14.23",
40+
"@types/react": "^15.0.22",
41+
"@types/react-dom": "^15.5.0",
4142
"action-emitter": "^0.2.1",
4243
"fbemitter": "^2.1.1",
4344
"immutable": "^3.8.1",
44-
"react": "15.4.2",
45-
"react-dom": "15.4.2",
45+
"react": "15.5.4",
46+
"react-dom": "^15.5.4",
4647
"typed-immutable-record": "^0.0.6"
4748
},
4849
"jest": {
@@ -57,4 +58,4 @@
5758
"js"
5859
]
5960
}
60-
}
61+
}

packages/simplr-forms-core/src/abstractions/base-form.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from "react";
22

33
import * as FormContracts from "../contracts/form";
4-
import { FSHContainer, FormStoresHandlerClass } from "../stores/form-stores-handler";
4+
import { FSHContainer, FormStoresHandler } from "../stores/form-stores-handler";
55

66
export abstract class BaseForm<TProps extends FormContracts.FormProps, TState> extends React.Component<TProps, TState> {
77
protected FormId: string;
@@ -25,7 +25,7 @@ export abstract class BaseForm<TProps extends FormContracts.FormProps, TState> e
2525
this.registerForm(props);
2626
}
2727

28-
protected get FormStoresHandler(): FormStoresHandlerClass {
28+
protected get FormStoresHandler(): FormStoresHandler {
2929
return FSHContainer.FormStoresHandler;
3030
}
3131

packages/simplr-forms-core/src/stores/form-stores-handler.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ActionEmitter } from "action-emitter";
44
import { FormStore } from "./form-store";
55
import * as Actions from "../actions/form-stores-handler";
66

7-
export class FormStoresHandlerClass extends ActionEmitter {
7+
export class FormStoresHandler extends ActionEmitter {
88
private storesCount: number;
99
private formStores: Immutable.Map<string, FormStore>;
1010

@@ -120,9 +120,9 @@ export class FormStoresHandlerClass extends ActionEmitter {
120120
}
121121

122122
export class FSHContainerClass {
123-
private instance: FormStoresHandlerClass;
123+
private instance: FormStoresHandler;
124124

125-
SetFormStoresHandler(newHandler: FormStoresHandlerClass, disposeOldOne: boolean = true) {
125+
SetFormStoresHandler(newHandler: FormStoresHandler, disposeOldOne: boolean = true) {
126126
if (disposeOldOne) {
127127
if (this.instance != null) {
128128
// Call internal method to reset stores
@@ -135,10 +135,10 @@ export class FSHContainerClass {
135135

136136
get FormStoresHandler() {
137137
if (this.instance == null) {
138-
this.instance = new FormStoresHandlerClass();
138+
this.instance = new FormStoresHandler();
139139
}
140140
return this.instance;
141141
}
142142
}
143143

144-
export var FSHContainer = new FSHContainerClass();
144+
export const FSHContainer = new FSHContainerClass();

0 commit comments

Comments
 (0)