-
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.
fix: add safety check for command.clone when cmd does not have args (#…
- Loading branch information
1 parent
b031803
commit d5c033f
Showing
2 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
packages/driver/cypress/integration/cypress/command_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,76 @@ | ||
const { Command } = Cypress | ||
|
||
describe('driver/src/cypress/command', () => { | ||
let command | ||
|
||
context('$Command', () => { | ||
context('._removeNonPrimitives', () => { | ||
before(() => { | ||
command = Command.create({ }) | ||
}) | ||
|
||
it('when args are undefined it does not remove non properties', () => { | ||
const args = undefined | ||
|
||
command._removeNonPrimitives(args) | ||
expect(args).to.be.undefined | ||
}) | ||
|
||
it('when args is an object it filters out non-primitive properties ', () => { | ||
const args = ['.fake_get_selector', { | ||
opt1: 'option', | ||
opt2: { | ||
nested: 'hello', | ||
}, | ||
}] | ||
|
||
command._removeNonPrimitives(args) | ||
expect(args).to.be.eq(args) | ||
}) | ||
|
||
it('sets log to true if previously options set it to false', () => { | ||
const args = [{ log: false }] | ||
|
||
command._removeNonPrimitives(args) | ||
expect(args).to.have.length(1) | ||
expect(args[0]).to.have.property('log') | ||
expect(args[0].log).to.be.true | ||
}) | ||
}) | ||
|
||
context('.clone', () => { | ||
it('successfully clones command with arguments', () => { | ||
const args = ['.selector'] | ||
|
||
command = Command.create({ | ||
type: 'parent', | ||
name: 'command1', | ||
chainerId: 'id1', | ||
args, | ||
}) | ||
|
||
const spy = cy.spy(command, '_removeNonPrimitives') | ||
let clonedCommand = command.clone() | ||
|
||
expect(clonedCommand).to.be.instanceOf(Command) | ||
expect(spy).to.have.been.calledWith(args) | ||
expect(clonedCommand.attributes).to.deep.eq(command.attributes) | ||
}) | ||
|
||
it('successfully clones command with without arguments', () => { | ||
command = Command.create({ | ||
type: 'parent', | ||
name: 'command1', | ||
chainerId: 'id1', | ||
}) | ||
|
||
const spy = cy.spy(command, '_removeNonPrimitives') | ||
let clonedCommand = command.clone() | ||
|
||
expect(clonedCommand).to.be.instanceOf(Command) | ||
expect(spy).to.have.been.calledWith(undefined) | ||
expect(clonedCommand.attributes).to.deep.eq(command.attributes) | ||
}) | ||
}) | ||
}) | ||
}) |
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
d5c033f
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:
d5c033f
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:
d5c033f
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
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: