mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-23 07:39:52 -06:00
driver: add test for cy.within callback context, remove unnecessary ensureDom check
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user