* Check actual is not null or undefined rather than a falsy value

This fixes an issue when checking if actual was an empty string

* Add test to check empty string attributes are handled as expected
This commit is contained in:
Heather Roberts
2018-03-26 01:55:54 +11:00
committed by Brian Mann
parent ba73e1cc5d
commit ae794d1f8c
2 changed files with 13 additions and 1 deletions

View File

@@ -224,7 +224,7 @@ $chaiJquery = (chai, chaiUtils, callbacks = {}) ->
assert(
@,
attr,
actual and actual is val,
actual? and actual is val,
message,
negatedMessage,
val,

View File

@@ -657,6 +657,18 @@ describe "src/cy/commands/assertions", ->
cy.get("body").then ($body) ->
expect($body).to.exist
it "matches empty string attributes", (done) ->
cy.on "log:added", (attrs, log) =>
if attrs.name is "assert"
cy.removeAllListeners("log:added")
expect(log.get("message")).to.eq "expected **<input>** to have attribute **value** with the value **''**"
done()
cy.$$("body").prepend $("<input value='' />")
cy.get("input").eq(0).then ($input) ->
expect($input).to.have.attr('value', '')
describe "without selector", ->
it "exists", (done) ->
cy.on "log:added", (attrs, log) =>