-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add keystrokeDelay * Config tests * Add proper comments * Add some tests for configuring timeout * Add tests for false values * Few additional tests * Rename test * feat: add Cypress.Keyboard.defaults() for specifying default keystrokeDelay * use test-configuration on link * remove obsolete error message * fix types and add type tests * fix types tests * fix type test Co-authored-by: Chris Breiding <chrisbreiding@gmail.com>
- Loading branch information
1 parent
929cac8
commit ce5abe4
Showing
7 changed files
with
334 additions
and
15 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
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
108 changes: 108 additions & 0 deletions
108
packages/driver/cypress/integration/cypress/keyboard_spec.js
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,108 @@ | ||
const { Keyboard } = Cypress | ||
|
||
const DEFAULTS = { | ||
keystrokeDelay: 10, | ||
} | ||
|
||
describe('src/cypress/keyboard', () => { | ||
beforeEach(() => { | ||
Keyboard.reset() | ||
}) | ||
|
||
it('has defaults', () => { | ||
expect(Keyboard.getConfig()).to.deep.eq(DEFAULTS) | ||
}) | ||
|
||
context('.getConfig', () => { | ||
it('returns config', () => { | ||
expect(Keyboard.getConfig()).to.deep.eq(DEFAULTS) | ||
}) | ||
|
||
it('does not allow mutation of config', () => { | ||
const config = Keyboard.getConfig() | ||
|
||
config.keystrokeDelay = 0 | ||
|
||
expect(Keyboard.getConfig().keystrokeDelay).to.eq(DEFAULTS.keystrokeDelay) | ||
}) | ||
}) | ||
|
||
context('.defaults', () => { | ||
it('is noop if not called with any valid properties', () => { | ||
Keyboard.defaults({}) | ||
expect(Keyboard.getConfig()).to.deep.eq(DEFAULTS) | ||
}) | ||
|
||
it('sets keystrokeDelay if specified', () => { | ||
Keyboard.defaults({ | ||
keystrokeDelay: 5, | ||
}) | ||
|
||
expect(Keyboard.getConfig().keystrokeDelay).to.eql(5) | ||
}) | ||
|
||
it('returns new config', () => { | ||
const result = Keyboard.defaults({ | ||
keystrokeDelay: 5, | ||
}) | ||
|
||
expect(result).to.deep.eql({ | ||
keystrokeDelay: 5, | ||
}) | ||
}) | ||
|
||
it('does not allow mutation via returned config', () => { | ||
const result = Keyboard.defaults({ | ||
keystrokeDelay: 5, | ||
}) | ||
|
||
result.keystrokeDelay = 0 | ||
|
||
expect(Keyboard.getConfig().keystrokeDelay).to.eq(5) | ||
}) | ||
|
||
describe('errors', () => { | ||
it('throws if not passed an object', () => { | ||
const fn = () => { | ||
Keyboard.defaults() | ||
} | ||
|
||
expect(fn).to.throw() | ||
.with.property('message') | ||
.and.eq('`Cypress.Keyboard.defaults()` must be called with an object. You passed: ``') | ||
|
||
expect(fn).to.throw() | ||
.with.property('docsUrl') | ||
.and.eq('https://on.cypress.io/keyboard-api') | ||
}) | ||
|
||
it('throws if keystrokeDelay is not a number', () => { | ||
const fn = () => { | ||
Keyboard.defaults({ keystrokeDelay: false }) | ||
} | ||
|
||
expect(fn).to.throw() | ||
.with.property('message') | ||
.and.eq('`Cypress.Keyboard.defaults()` `keystrokeDelay` option must be 0 (zero) or a positive number. You passed: `false`') | ||
|
||
expect(fn).to.throw() | ||
.with.property('docsUrl') | ||
.and.eq('https://on.cypress.io/keyboard-api') | ||
}) | ||
|
||
it('throws if keystrokeDelay is a negative number', () => { | ||
const fn = () => { | ||
Keyboard.defaults({ keystrokeDelay: -10 }) | ||
} | ||
|
||
expect(fn).to.throw() | ||
.with.property('message') | ||
.and.eq('`Cypress.Keyboard.defaults()` `keystrokeDelay` option must be 0 (zero) or a positive number. You passed: `-10`') | ||
|
||
expect(fn).to.throw() | ||
.with.property('docsUrl') | ||
.and.eq('https://on.cypress.io/keyboard-api') | ||
}) | ||
}) | ||
}) | ||
}) |
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
Oops, something went wrong.
ce5abe4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
linux x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
ce5abe4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AppVeyor has built the
win32 x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
ce5abe4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AppVeyor has built the
win32 ia32
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
ce5abe4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
darwin x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally: