Skip to content

Commit 6009860

Browse files
Merge pull request #12 from gokulakannant/develop
Develop
2 parents 6045d1b + 9a53cb1 commit 6009860

File tree

14 files changed

+277
-13403
lines changed

14 files changed

+277
-13403
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ node_modules/
22
dist
33
Documentation
44
example/package-lock.json
5+
example/yarn.lock

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
A customized [validatorjs](https://www.npmjs.com/package/validatorjs) library to validate the react forms. It uses the [Controlled Components](https://reactjs.org/docs/forms.html#controlled-components) approach for validation.
88

99
* [Supported Rules](https://www.npmjs.com/package/validatorjs#available-rules) (It is supports all validatorjs rules)
10-
* [Documentation](https://gokulakannant.github.io/react-form-input-validation/v2.0.1/index.html)
10+
* [Documentation](https://gokulakannant.github.io/react-form-input-validation/index.html)
1111
* [Demo](https://codesandbox.io/s/react-form-input-validation-demp-hyuju?fontsize=14&hidenavigation=1&theme=dark) (in CodeSandbox)
1212

1313
## Why use react-form-input-validation?
@@ -36,7 +36,7 @@ Using [yarn](https://yarnpkg.com/en/) as your package manager.
3636

3737
## Usage
3838

39-
A example form has given below. View all available apis in [documentation](https://gokulakannant.github.io/react-form-input-validation/v2.0.1/index.html).
39+
A example form has given below. View all available apis in [documentation](https://gokulakannant.github.io/react-form-input-validation/classes/reactforminputvalidation.html).
4040

4141
```js
4242
import React from "react";
@@ -170,7 +170,7 @@ The input types button, submit, reset, hidden are exceptional from the above lis
170170

171171
## Versions
172172

173-
Latest Version: 2.0.1. For more versions refer [VERSIONS.md](VERSIONS.md).
173+
Latest Version: 2.0.2. For more versions refer [VERSIONS.md](VERSIONS.md).
174174

175175
## Changelog
176176

VERSIONS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The most recent version is recommended in production.
1010
|--------|---------|--------|
1111
|v2.0.1|[Documentation](https://gokulakannant.github.io/react-form-input-validation/v2.0.1/index.html)|[Release notes](https://github.com/gokulakannant/react-form-input-validation/releases/tag/v2.0.1)|
1212
|v2.0.0|[Documentation](https://gokulakannant.github.io/react-form-input-validation/v2.0.0/index.html)|[Release notes](https://github.com/gokulakannant/react-form-input-validation/releases/tag/v2.0.0)|
13-
|v1.0.1|[Documentation](https://gokulakannant.github.io/react-form-input-validation/index.html)| |
13+
|v1.0.1|[Documentation](https://gokulakannant.github.io/react-form-input-validation/v1.0.1/index.html)| |
1414

1515
## Versioning strategy
1616

example/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SKIP_PREFLIGHT_CHECK=true

example/cypress.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
describe('The Home Page', function() {
2+
it('Successfull rendering', function() {
3+
cy.visit('http://localhost:3000/')
4+
})
5+
6+
it('Check Submit Button', function() {
7+
cy.visit('http://localhost:3000/')
8+
cy.contains('Submit Booking').click()
9+
});
10+
});
11+
12+
describe("Test blur events", () => {
13+
it('Successfull rendering', function() {
14+
cy.visit('http://localhost:3000/')
15+
})
16+
17+
it("Customer Name blur (Text field)", () => {
18+
cy.get('input[name=customer_name]').focus().blur();
19+
cy.contains("The Customer Name field is required.")
20+
});
21+
22+
it("Phone number blur (Text field)", () => {
23+
cy.get('input[name=phone_number]').focus().blur();
24+
cy.contains("The phone number field is required.");
25+
});
26+
27+
it("Email address blur (Text field)", () => {
28+
cy.get('input[name=email_address]').focus().blur();
29+
cy.contains("The email address field is required.");
30+
});
31+
32+
it("Pickup Date blur (Date field)", () => {
33+
cy.get('input[name=pickup_time]').focus().blur();
34+
cy.contains("The pickup time field is required.");
35+
});
36+
37+
it("Pickup Place blur (Dropdown)", () => {
38+
cy.get('select[name=pickup_place]').focus().blur();
39+
cy.contains("The pickup place field is required.");
40+
});
41+
42+
it("Drop Place blur (Combo box)", () => {
43+
cy.get('input[name=dropoff_place]').focus().blur();
44+
cy.contains("The dropoff place field is required.");
45+
});
46+
47+
it("Special instructions blur (Textarea)", () => {
48+
cy.get('textarea').focus().blur();
49+
cy.contains("The comments field is required.");
50+
});
51+
});
52+
53+
describe("Test change event", () => {
54+
it('Successfull rendering', function() {
55+
cy.visit('http://localhost:3000/')
56+
});
57+
58+
it("Customer Name change event (Text field)", () => {
59+
cy.get('input[name=customer_name]').focus().blur();
60+
cy.get('input[name=customer_name]').type("gokulakannan").blur();
61+
cy.contains("The Customer Name field is required.").should('not.exist');
62+
});
63+
64+
it("Phone number change (Text field)", () => {
65+
cy.get('input[name=phone_number]').focus().blur();
66+
cy.get('input[name=phone_number]').type(9876543210).blur();
67+
cy.contains("The phone number field is required.").should('not.exist');
68+
});
69+
70+
it("Email address blur (Text field)", () => {
71+
cy.get('input[name=email_address]').focus().blur();
72+
cy.get('input[name=email_address]').type("[email protected]").blur();
73+
cy.contains("The email address field is required.").should('not.exist');
74+
});
75+
76+
it("Pickup Date blur (Date field)", () => {
77+
cy.get('input[name=pickup_time]').focus().blur();
78+
cy.get('input[name=pickup_time]').type("2019-11-27").blur();
79+
cy.contains("The pickup time field is required.").should('not.exist');
80+
});
81+
82+
it("Pickup Place blur (Dropdown)", () => {
83+
cy.get('select[name=pickup_place]').focus().blur();
84+
cy.get('select[name=pickup_place]').select('town_hall');
85+
// cy.contains("The pickup place field is required.").should('not.exist');
86+
});
87+
88+
it("Drop Place blur (Combo box)", () => {
89+
cy.get('input[name=dropoff_place]').focus().blur();
90+
cy.get('input[name=dropoff_place]').type("Airport").blur();
91+
cy.contains("The dropoff place field is required.").should('not.exist');
92+
});
93+
94+
it("Special instructions blur (Textarea)", () => {
95+
cy.get('textarea').focus().blur();
96+
cy.get('textarea').type("Use react form input validator for testing").blur();
97+
cy.contains("The comments field is required.").should('not.exist');
98+
});
99+
});
100+
101+
describe("Fill form fields", () => {
102+
it('Successfull rendering', function() {
103+
cy.visit('http://localhost:3000/')
104+
});
105+
106+
it("Type customer name (Text field)", () => {
107+
cy.get('input[name=customer_name]').type("gokulakannan").blur();
108+
});
109+
110+
it("Type phone number (Text field)", () => {
111+
cy.get('input[name=phone_number]').type(9876543210).blur();
112+
});
113+
114+
it("Type email address (Text field)", () => {
115+
cy.get('input[name=email_address]').type("[email protected]").blur();
116+
});
117+
118+
it("Select Taxi (Radio button)", () => {
119+
cy.get('[type="radio"]').first().check()
120+
});
121+
122+
it("Check extras (Checkbox)", () => {
123+
cy.get('[type="checkbox"]').check(['baby', 'wheelchair'])
124+
});
125+
126+
it("Select pickup Date (Date field)", () => {
127+
cy.get('input[name=pickup_time]').type("2019-11-27").blur();
128+
});
129+
130+
it("Select pickup Place (Dropdown)", () => {
131+
cy.get('select[name=pickup_place]').select('town_hall')
132+
});
133+
134+
it("Choose drop Place (Combo box)", () => {
135+
cy.get('input[name=dropoff_place]').type("Airport").blur();
136+
});
137+
138+
it("Type Special instructions (Textarea)", () => {
139+
cy.get('textarea').type("Use react form input validator for testing").blur();
140+
cy.contains("The comments field is required.").should('not.exist');
141+
});
142+
});
143+
144+
describe("Test validation rules in form fields", () => {
145+
beforeEach("Render home page", () => {
146+
cy.visit('http://localhost:3000/');
147+
})
148+
describe("Customer name (required)", () => {
149+
it("Empty fields should display error message", () => {
150+
cy.get('input[name=customer_name]').focus().blur();
151+
cy.contains("The Customer Name field is required.");
152+
});
153+
154+
it("Valid data should not display error message", () => {
155+
cy.get('input[name=customer_name]').focus().blur();
156+
cy.get('input[name=customer_name]').type("gokulakannan").blur();
157+
cy.contains("The Customer Name field is required.").should('not.exist');
158+
});
159+
});
160+
161+
describe("Phone number (numeric, min, max)", () => {
162+
it("Invalid alphabet phone number should display error message", () => {
163+
cy.get('input[name=phone_number]').type("test").blur();
164+
cy.contains("The phone number must be a number.");
165+
});
166+
167+
it("Min length phone number should display error message", () => {
168+
cy.get('input[name=phone_number]').type(321).blur();
169+
cy.contains("The phone number field must be between 10 and 12 digits.");
170+
});
171+
172+
it("Max length phone number should display error message", () => {
173+
cy.get('input[name=phone_number]').type(321).blur();
174+
cy.contains("The phone number field must be between 10 and 12 digits.");
175+
});
176+
177+
it("Valid phone number should not display error message", () => {
178+
cy.get('input[name=phone_number]').type(9876543210).blur();
179+
cy.contains("The phone number must be a number.").should('not.exist');
180+
});
181+
});
182+
183+
describe("Email address (email)", () => {
184+
it("Invalid email address should display error message", () => {
185+
cy.get('input[name=email_address]').type("test").blur();
186+
cy.contains("The email address format is invalid.");
187+
});
188+
189+
it("Valid email address should not display error message", () => {
190+
cy.get('input[name=email_address]').type("[email protected]").blur();
191+
cy.contains("The email address format is invalid.").should('not.exist');
192+
});
193+
});
194+
})

example/cypress/plugins/index.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// ***********************************************************
2+
// This example plugins/index.js can be used to load plugins
3+
//
4+
// You can change the location of this file or turn off loading
5+
// the plugins file with the 'pluginsFile' configuration option.
6+
//
7+
// You can read more here:
8+
// https://on.cypress.io/plugins-guide
9+
// ***********************************************************
10+
11+
// This function is called when a project is opened or re-opened (e.g. due to
12+
// the project's config changing)
13+
14+
module.exports = (on, config) => {
15+
// `on` is used to hook into various events Cypress emits
16+
// `config` is the resolved Cypress config
17+
}

example/cypress/support/commands.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// ***********************************************
2+
// This example commands.js shows you how to
3+
// create various custom commands and overwrite
4+
// existing commands.
5+
//
6+
// For more comprehensive examples of custom
7+
// commands please read more here:
8+
// https://on.cypress.io/custom-commands
9+
// ***********************************************
10+
//
11+
//
12+
// -- This is a parent command --
13+
// Cypress.Commands.add("login", (email, password) => { ... })
14+
//
15+
//
16+
// -- This is a child command --
17+
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
18+
//
19+
//
20+
// -- This is a dual command --
21+
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
22+
//
23+
//
24+
// -- This will overwrite an existing command --
25+
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })

example/cypress/support/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// ***********************************************************
2+
// This example support/index.js is processed and
3+
// loaded automatically before your test files.
4+
//
5+
// This is a great place to put global configuration and
6+
// behavior that modifies Cypress.
7+
//
8+
// You can change the location of this file or turn off
9+
// automatically serving support files with the
10+
// 'supportFile' configuration option.
11+
//
12+
// You can read more here:
13+
// https://on.cypress.io/configuration
14+
// ***********************************************************
15+
16+
// Import commands.js using ES2015 syntax:
17+
import './commands'
18+
19+
// Alternatively you can use CommonJS syntax:
20+
// require('./commands')

0 commit comments

Comments
 (0)