driver: add test for cy.within callback context, remove unnecessary ensureDom check

This commit is contained in:
Brian Mann
2017-08-31 23:05:41 -04:00
parent 19e1a634f6
commit ab9924cb5a
2 changed files with 8 additions and 2 deletions

View File

@@ -418,7 +418,7 @@ module.exports = (Commands, Cypress, cy, state, config) ->
Commands.addAll({ prevSubject: "dom"}, {
within: (subject, options, fn) ->
cy.ensureDom(subject)
ctx = @
if _.isUndefined(fn)
fn = options
@@ -447,7 +447,7 @@ module.exports = (Commands, Cypress, cy, state, config) ->
prevWithinSubject = cy.state("withinSubject")
cy.state("withinSubject", subject)
fn.call cy.state("runnable").ctx, subject
fn.call(ctx, subject)
cleanup = ->
cy.removeListener("command:start", setWithinSubject)

View File

@@ -219,6 +219,12 @@ describe "src/cy/commands/querying", ->
cy.focused().should("have.class", "focused")
context "#within", ->
it "invokes callback function with runnable.ctx", ->
ctx = @
cy.get("div:first").within ->
expect(ctx is @).to.be.true
it "scopes additional GET finders to the subject", ->
input = cy.$$("#by-name input:first")