Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add hasChanged and hasBlurred props to useField * Add cypress testing * Add circleci cache for docs * Add node cache alias (test) * Update aliases * move things around * bug-reproduction * Add tests for examples * Add dependency to deploy ci step * Fix prettier anomoly * Remove vars
- Loading branch information
1 parent
9524312
commit 6c12d5b
Showing
13 changed files
with
410 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"baseUrl": "http://localhost:1234", | ||
"fixturesFolder": false, | ||
"pluginsFile": false, | ||
"supportFile": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
beforeEach(() => { | ||
cy.visit('/'); | ||
}); | ||
|
||
describe('username', () => { | ||
it('changes value', () => { | ||
const value = 'hi'; | ||
cy.get('input[name="username"]') | ||
.type(value) | ||
.should('have.value', value); | ||
}); | ||
|
||
it('validates on blur', () => { | ||
cy.get('input[name="username"]') | ||
.type('hi') | ||
.blur() | ||
.next() | ||
.should('contain.text', 'Username must be at least 4 characters.'); | ||
}); | ||
|
||
it('updates validation on change', () => { | ||
cy.get('input[name="username"]') | ||
.type('hi') | ||
.blur() | ||
.type('hello there') | ||
.next() | ||
.should('not.contain.text', 'Username must be at least 4 characters.'); | ||
}); | ||
}); | ||
|
||
describe('password', () => { | ||
it('changes value', () => { | ||
const value = 'hi'; | ||
|
||
cy.get('input[name="password"]') | ||
.type(value) | ||
.should('have.value', value); | ||
}); | ||
|
||
it('validates on blur', () => { | ||
cy.get('input[name="password"]') | ||
.type('hi') | ||
.blur() | ||
.next() | ||
.should('contain.text', 'Password must be at least 4 characters.'); | ||
}); | ||
|
||
it('updates validation on change', () => { | ||
cy.get('input[name="password"]') | ||
.type('hi') | ||
.blur() | ||
.type('hello there') | ||
.next() | ||
.should('not.contain.text', 'Password must be at least 4 characters.'); | ||
}); | ||
}); | ||
|
||
describe('next button', () => { | ||
it('is disabled on mount', () => { | ||
cy.get('button').should('have.attr', 'disabled'); | ||
}); | ||
|
||
it('is enabled when fields are valid', () => { | ||
cy.get('input[name="username"]').type('hello there'); | ||
cy.get('input[name="password"]').type('hello there'); | ||
cy.get('button').should('not.have.attr', 'disabled'); | ||
}); | ||
|
||
it('is disabled when fields are invalid', () => { | ||
cy.get('input[name="username"]').type('hello there'); | ||
cy.get('input[name="password"]').type('hello there'); | ||
cy.get('input[name="password"]') | ||
.clear() | ||
.type('hi'); | ||
cy.get('button').should('have.attr', 'disabled'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true, | ||
"baseUrl": "../node_modules", | ||
"target": "es5", | ||
"lib": ["es5", "dom"], | ||
"types": ["cypress"] | ||
}, | ||
"include": ["**/*.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"baseUrl": "http://localhost:1234", | ||
"fixturesFolder": false, | ||
"pluginsFile": false, | ||
"supportFile": false | ||
} |
Oops, something went wrong.