diff --git a/src/Checkbox/__tests__/checkbox.test.js b/src/Checkbox/__tests__/checkbox.test.js
index 7a71b3c6..5871f5d7 100755
--- a/src/Checkbox/__tests__/checkbox.test.js
+++ b/src/Checkbox/__tests__/checkbox.test.js
@@ -30,6 +30,24 @@ describe("Test checkbox component", () => {
const tree = renderer.create().toJSON();
expect(tree).toMatchSnapshot();
});
+
+ it("get status returns null if prestate is true, required and not checked", () => {
+ const prestate = true;
+ const cb = mount();
+ expect(cb.instance()._getStatus(prestate)).toBe(null);
+ });
+
+ it("get status returns null if prestate is true, not required", () => {
+ const prestate = true;
+ const cb = mount();
+ expect(cb.instance()._getStatus(prestate)).toBe(null);
+ });
+
+ it("get status returns error if prestate is false, required", () => {
+ const prestate = false;
+ const cb = mount();
+ expect(cb.instance()._getStatus(prestate)).toBe("error");
+ });
});
describe("Test checkbox component - Default values", () => {
@@ -119,7 +137,7 @@ describe("Test checkbox component - Default values", () => {
expect(handleChange).toBeCalled();
});
- it("Test checkbox component - Click event (custom onBeforeChange)", function() {
+ it("Test checkbox component - Click event (custom onBeforeChange returns false)", function() {
const comp = mount(
{
expect(comp.state().checked).toEqual(false);
});
+ it("Test checkbox component - Click event (custom onBeforeChange returns true)", function() {
+ const comp = mount(
+
+ );
+ expect(comp.state().checked).toEqual(false);
+ comp.simulate("click");
+ expect(comp.state().checked).toEqual(true);
+ });
+
it("Test checkbox component - labelPosition left", function() {
const comp = mount();
expect(comp.find(".float_right").exists()).toBe(true);
diff --git a/src/Dropdown/__tests__/dropdown.test.js b/src/Dropdown/__tests__/dropdown.test.js
index 619dcd4b..314b3e17 100755
--- a/src/Dropdown/__tests__/dropdown.test.js
+++ b/src/Dropdown/__tests__/dropdown.test.js
@@ -459,4 +459,26 @@ describe("Test Dropdown component - setOptions() method", () => {
expect(event.persist).toBeCalled();
expect(event.preventDefault).toBeCalled();
});
+
+ it("_formValidate sets state & returns validationObject", () => {
+ const expectedValidationObject = {
+ status: null,
+ message: null
+ };
+ const dd = mount(
+
+ );
+ expect(dd.instance()._formValidate("true")).toEqual(
+ expectedValidationObject
+ );
+ expect(dd.state().status).toBe(expectedValidationObject.status);
+ expect(dd.state().message).toBe(expectedValidationObject.message);
+ });
});
diff --git a/src/TextArea/__tests__/textArea.test.js b/src/TextArea/__tests__/textArea.test.js
index 6d19a625..b3345770 100755
--- a/src/TextArea/__tests__/textArea.test.js
+++ b/src/TextArea/__tests__/textArea.test.js
@@ -149,4 +149,17 @@ describe("Test Text component", () => {
"this field is required"
);
});
+
+ it("_formValidate sets state and returns validationObject", function() {
+ const expectedValidationObject = {
+ status: null,
+ message: null
+ };
+ const ta = mount();
+ expect(ta.instance()._formValidate("foo")).toEqual(
+ expectedValidationObject
+ );
+ expect(ta.state().status).toBe(expectedValidationObject.status);
+ expect(ta.state().message).toBe(expectedValidationObject.message);
+ });
});
diff --git a/src/TextField/__tests__/textField.test.js b/src/TextField/__tests__/textField.test.js
index 56235e1a..dd5ae6f1 100755
--- a/src/TextField/__tests__/textField.test.js
+++ b/src/TextField/__tests__/textField.test.js
@@ -103,6 +103,30 @@ describe("Suite - events", () => {
expect(handleFocus).toBeCalled();
});
+ it("focus does not call onFocus if onFocus is not a function", () => {
+ const handleFocus = jest.fn();
+ const tf = mount();
+
+ tf.find("input").simulate("focus");
+ expect(handleFocus).not.toBeCalled();
+ });
+
+ it("click calls onClick if onClick is a function", () => {
+ const handleClick = jest.fn();
+ const tf = mount();
+
+ tf.find("input").simulate("click");
+ expect(handleClick).toBeCalled();
+ });
+
+ it("click does not call onClick if onClick is not a function", () => {
+ const handleClick = jest.fn();
+ const tf = mount();
+
+ tf.find("input").simulate("click");
+ expect(handleClick).not.toBeCalled();
+ });
+
it("handle paste with no mask", () => {
const event = {
preventDefault: jest.fn(),