New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
property assertion should only accept strings if nested, fixes #1043 #1044
Changes from 1 commit
e167009
3f2ce29
335fd33
5fd4fa2
8ff7cb7
a078a6d
e1442d0
d58d2bf
84062b1
f9e5a68
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1465,7 +1465,7 @@ describe('expect', function () { | |
|
||
expect(function () { | ||
expect({a:1}).to.have.property(null); | ||
}).to.throw('the argument to `property` must be either of type string, number or symbol'); | ||
}).to.throw('the argument to property must be a string, number, or symbol'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should use the |
||
}); | ||
|
||
it('property(name, val)', function(){ | ||
|
@@ -1762,7 +1762,7 @@ describe('expect', function () { | |
|
||
expect(function () { | ||
expect({a:1}).to.have.nested.property({'a':'1'}); | ||
}).to.throw('the argument to `property` must be a string'); | ||
}).to.throw('the argument to property must be a string when using nested syntax'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should use the |
||
}); | ||
|
||
it('nested.property(name, val)', function(){ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
describe('should', function() { | ||
var should = chai.Should(); | ||
var expect = chai.expect; | ||
|
||
it('assertion', function(){ | ||
'test'.should.be.a('string'); | ||
|
@@ -1410,13 +1409,13 @@ describe('should', function() { | |
|
||
({a:1}).should.have.nested.property('a'); | ||
|
||
expect(function () { | ||
(function () { | ||
({a:1}).should.have.nested.property('{a:1}'); | ||
}).to.not.throw('the argument to `property` must be a string'); | ||
}).should.not.throw('the argument to property must be a string when using nested syntax'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's remove this test. We already test that |
||
|
||
expect(function () { | ||
(function () { | ||
({a:1}).should.have.nested.property({'a':'1'}); | ||
}).to.throw('the argument to `property` must be a string'); | ||
}).should.throw('the argument to property must be a string when using nested syntax'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should use the |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One more test should be added here to the |
||
err(function(){ | ||
({ 'foo.bar': 'baz' }).should.have.nested.property('foo.bar'); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we are using
chai.expect
on line 18 too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's shouldn't be wrong to use
expect
in this test, because here we are actually usingchai
to assert, we are not callingassertions
and expecting them to work, we are testing that the assertionthrows
.But I agree with @meeber that we must try and be able to use own
interface
to test it.You can replace the ones you added on this PR with
assert.throws
andassert.doesNotThrows
and maybe remove the others in another PR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure @vieiralucas . I have replaced them and also surely will open a seperate PR in future to replace the remaining.