Socket
Socket
Sign inDemoInstall

chai-dom

Package Overview
Dependencies
78
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.9.0 to 1.10.0

15

chai-dom.js

@@ -389,2 +389,17 @@ (function(chaiDom) {

})
chai.Assertion.overwriteProperty('focus', function() {
return function () {
var el = flag(this, 'object'), actual = el.ownerDocument.activeElement
this.assert(
el === el.ownerDocument.activeElement
, 'expected #{this} to have focus'
, 'expected #{this} not to have focus'
, el
, actual
)
}
})
}));

2

package.json

@@ -16,3 +16,3 @@ {

],
"version": "1.9.0",
"version": "1.10.0",
"license": "MIT",

@@ -19,0 +19,0 @@ "repository": {

@@ -187,2 +187,11 @@ # chai-dom

### `focus`
Assert that the [HTMLElement][] has set focus.
```js
document.querySelector('input').should.have.focus
expect(document.querySelector('.container')).not.to.have.focus
```
## Installation

@@ -189,0 +198,0 @@

@@ -1001,2 +1001,39 @@ describe('DOM assertions', function() {

})
describe('focus', function() {
var container = document.getElementById("mocha");
var focused = parse('<input type="text" id="focused" name="focused">');
var blurred = parse('<input type="text" id="blurred" name="blurred">');
beforeEach(function() {
container.appendChild(focused)
container.appendChild(blurred)
focused.focus();
});
afterEach(function() {
container.removeChild(focused)
container.removeChild(blurred)
});
it("passes when the element has focus", function(){
focused.should.have.focus;
});
it("passes negated when the element does not have focus", function(){
blurred.should.not.have.focus;
});
it("fails when the element does not have focus", function(){
(function(){
blurred.should.have.focus;
}).should.fail("expected " + inspect(blurred) + " to have focus");
});
it("fails negated when element has focus", function(){
(function(){
focused.should.not.have.focus;
}).should.fail("expected " + inspect(focused) + " not to have focus");
});
})
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc