Skip to content

Commit

Permalink
Adding the options normalizing step for open API (#1447)
Browse files Browse the repository at this point in the history
* Adding the normalizing step for open API

* Adding tests to ensure normalization happens
  • Loading branch information
Aftabnack authored and jennifer-shehane committed May 15, 2018
1 parent 8188a44 commit d857237
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
4 changes: 4 additions & 0 deletions cli/__snapshots__/cypress_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ exports['cypress .run resolves with contents of tmp file 1'] = {
"code": 0,
"failingTests": []
}

exports['cypress .open normalizes config object 1'] = {
"config": "pageLoadTime=10000,watchForFileChanges=false"
}
1 change: 1 addition & 0 deletions cli/lib/cypress.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const util = require('./util')

const cypressModuleApi = {
open (options = {}) {
options = util.normalizeModuleOptions(options)
return open.start(options)
},

Expand Down
26 changes: 24 additions & 2 deletions cli/test/lib/cypress_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,32 @@ const cypress = require(`${lib}/cypress`)

describe('cypress', function () {
context('.open', function () {
it('calls open#start, passing in options', function () {
beforeEach(function () {
this.sandbox.stub(open, 'start').resolves()
})

const getCallArgs = R.path(['lastCall', 'args', 0])
const getStartArgs = () => {
expect(open.start).to.be.called
return getCallArgs(open.start)
}

it('calls open#start, passing in options', function () {
cypress.open({ foo: 'foo' })
expect(open.start).to.be.calledWith({ foo: 'foo' })
.then(getStartArgs)
.then((args) => {
expect(args.foo).to.equal('foo')
})
})

it('normalizes config object', () => {
const config = {
pageLoadTime: 10000,
watchForFileChanges: false,
}
cypress.open({ config })
.then(getStartArgs)
.then(snapshot)
})
})

Expand Down

0 comments on commit d857237

Please sign in to comment.