Comparing version 1.8.1 to 1.8.2
@@ -346,2 +346,14 @@ (function(chaiDom) { | ||
}) | ||
chai.Assertion.addMethod('tagName', function(tagName) { | ||
var el = flag(this, 'object'), | ||
actual = el.tagName; | ||
this.assert( | ||
actual.toUpperCase() === tagName.toUpperCase() | ||
, 'expected ' + elToString(el) + ' to have tagName ' + tagName + ', but it was ' + actual | ||
, 'expected ' + elToString(el) + ' to not have tagName ' + tagName + ', but it was ' + actual | ||
, actual | ||
) | ||
}) | ||
})); |
@@ -16,3 +16,4 @@ { | ||
], | ||
"version": "1.8.1", | ||
"version": "1.8.2", | ||
"license": "MIT", | ||
"repository": { | ||
@@ -19,0 +20,0 @@ "type": "git", |
@@ -167,2 +167,10 @@ # chai-dom | ||
### `tagName(name)` | ||
Assert that the [HTMLElement][] has the given tagName. | ||
```js | ||
document.querySelector('.container').should.have.tagName('div') | ||
expect(document.querySelector('.container')).not.to.have.tagName('span') | ||
``` | ||
## Installation | ||
@@ -169,0 +177,0 @@ |
@@ -859,2 +859,28 @@ describe('DOM assertions', function() { | ||
describe('tagName', function() { | ||
var div = document.createElement('div'), | ||
divWithContent = parse('<div><span>test</span></div>'), | ||
span = parse('<span>Test</span>') | ||
it('passes when the tagName is equal', function() { | ||
div.should.have.tagName('div') | ||
divWithContent.should.have.tagName('div') | ||
span.should.have.tagName('span') | ||
}) | ||
it('passes case insensitive', function() { | ||
div.should.have.tagName('DIV') | ||
div.should.have.tagName('diV') | ||
}) | ||
it('passes negated', function() { | ||
div.should.not.have.tagName('somethingelse') | ||
span.should.not.have.tagName('div') | ||
}) | ||
it('should be chainable', function() { | ||
div.should.have.tagName('div').and.exist.and.be.ok | ||
}) | ||
}) | ||
describe('util.elToString', function() { | ||
@@ -861,0 +887,0 @@ it('should give a friendly name for a HTMLElement', function() { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56354
1087
229