Skip to content

Commit 58c0a06

Browse files
committed
Remove 'not to have attributes'. The negative match doesn't seem to have a big enough use case for attributes
1 parent 5d91d2d commit 58c0a06

File tree

2 files changed

+7
-37
lines changed

2 files changed

+7
-37
lines changed

lib/index.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,18 @@ module.exports = {
6969
}
7070
});
7171

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

7575
if (typeof cmp === 'string') {
76-
expect(attrs, '[not] to [only] have keys', Array.prototype.slice.call(arguments, 2));
76+
expect(attrs, 'to [only] have keys', Array.prototype.slice.call(arguments, 2));
7777
} else if (Array.isArray(cmp)) {
78-
expect(attrs, '[not] to [only] have keys', cmp);
78+
expect(attrs, 'to [only] have keys', cmp);
79+
} else {
80+
expect(attrs, '');
7981
}
82+
83+
8084
});
8185
}
8286
};

test/unexpected-dom.js

-34
Original file line numberDiff line numberDiff line change
@@ -73,23 +73,6 @@ describe('unexpected-dom', function () {
7373
expect(err.output.toString(), 'to be', 'expected <button class="bar" data-info="baz" disabled="" id="foo"/> to have attributes \'id\', \'foo\'');
7474
});
7575
});
76-
77-
it('should match negative arguments', function () {
78-
this.body.innerHTML = '<button id="foo" class="bar" data-info="baz" disabled>Press me</button>';
79-
80-
expect(this.body.firstChild, 'not to have attributes', 'foo', 'bar');
81-
});
82-
83-
it('should fail on negative partial arguments met', function () {
84-
this.body.innerHTML = '<button id="foo" class="bar" data-info="baz" disabled>Press me</button>';
85-
var el = this.body.firstChild;
86-
87-
expect(function () {
88-
expect(el, 'not to have attributes', 'id');
89-
}, 'to throw exception', function (err) {
90-
expect(err.output.toString(), 'to be', 'expected <button class="bar" data-info="baz" disabled="" id="foo"/> not to have attributes \'id\'');
91-
});
92-
});
9376
});
9477

9578
describe('array comparison', function () {
@@ -126,23 +109,6 @@ describe('unexpected-dom', function () {
126109
expect(err.output.toString(), 'to be', 'expected <button class="bar" data-info="baz" disabled="" id="foo"/> to have attributes [ \'id\', \'foo\' ]');
127110
});
128111
});
129-
130-
it('should match negative arguments', function () {
131-
this.body.innerHTML = '<button id="foo" class="bar" data-info="baz" disabled>Press me</button>';
132-
133-
expect(this.body.firstChild, 'not to have attributes', ['foo', 'bar']);
134-
});
135-
136-
it('should fail on negative partial arguments met', function () {
137-
this.body.innerHTML = '<button id="foo" class="bar" data-info="baz" disabled>Press me</button>';
138-
var el = this.body.firstChild;
139-
140-
expect(function () {
141-
expect(el, 'not to have attributes', ['id']);
142-
}, 'to throw exception', function (err) {
143-
expect(err.output.toString(), 'to be', 'expected <button class="bar" data-info="baz" disabled="" id="foo"/> not to have attributes [ \'id\' ]');
144-
});
145-
});
146112
});
147113
});
148114

0 commit comments

Comments
 (0)