Skip to content

Commit

Permalink
Remove 'not to have attributes'. The negative match doesn't seem to h…
Browse files Browse the repository at this point in the history
…ave a big enough use case for attributes
  • Loading branch information
Munter committed Mar 4, 2015
1 parent 5d91d2d commit 58c0a06
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 37 deletions.
10 changes: 7 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,18 @@ module.exports = {
}
});

expect.addAssertion('HTMLElement', ['[not] to [only] have (attribute|attributes)', '[not] to have (attribute|attributes)'], function (expect, subject, cmp) {
expect.addAssertion('HTMLElement', ['to [only] have (attribute|attributes)'], function (expect, subject, cmp) {
var attrs = getAttributes(subject);

if (typeof cmp === 'string') {
expect(attrs, '[not] to [only] have keys', Array.prototype.slice.call(arguments, 2));
expect(attrs, 'to [only] have keys', Array.prototype.slice.call(arguments, 2));
} else if (Array.isArray(cmp)) {
expect(attrs, '[not] to [only] have keys', cmp);
expect(attrs, 'to [only] have keys', cmp);
} else {
expect(attrs, '');
}


});
}
};
34 changes: 0 additions & 34 deletions test/unexpected-dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,6 @@ describe('unexpected-dom', function () {
expect(err.output.toString(), 'to be', 'expected <button class="bar" data-info="baz" disabled="" id="foo"/> to have attributes \'id\', \'foo\'');
});
});

it('should match negative arguments', function () {
this.body.innerHTML = '<button id="foo" class="bar" data-info="baz" disabled>Press me</button>';

expect(this.body.firstChild, 'not to have attributes', 'foo', 'bar');
});

it('should fail on negative partial arguments met', function () {
this.body.innerHTML = '<button id="foo" class="bar" data-info="baz" disabled>Press me</button>';
var el = this.body.firstChild;

expect(function () {
expect(el, 'not to have attributes', 'id');
}, 'to throw exception', function (err) {
expect(err.output.toString(), 'to be', 'expected <button class="bar" data-info="baz" disabled="" id="foo"/> not to have attributes \'id\'');
});
});
});

describe('array comparison', function () {
Expand Down Expand Up @@ -126,23 +109,6 @@ describe('unexpected-dom', function () {
expect(err.output.toString(), 'to be', 'expected <button class="bar" data-info="baz" disabled="" id="foo"/> to have attributes [ \'id\', \'foo\' ]');
});
});

it('should match negative arguments', function () {
this.body.innerHTML = '<button id="foo" class="bar" data-info="baz" disabled>Press me</button>';

expect(this.body.firstChild, 'not to have attributes', ['foo', 'bar']);
});

it('should fail on negative partial arguments met', function () {
this.body.innerHTML = '<button id="foo" class="bar" data-info="baz" disabled>Press me</button>';
var el = this.body.firstChild;

expect(function () {
expect(el, 'not to have attributes', ['id']);
}, 'to throw exception', function (err) {
expect(err.output.toString(), 'to be', 'expected <button class="bar" data-info="baz" disabled="" id="foo"/> not to have attributes [ \'id\' ]');
});
});
});
});

Expand Down

0 comments on commit 58c0a06

Please sign in to comment.