Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed `.a('object')` with nulls. Fixed english in error message.

  • Loading branch information...
commit 8c0efa1c78afd5e19fedcd50316c695ba5be73a3 1 parent 4005823
Guillermo Rauch rauchg authored
Showing with 9 additions and 3 deletions.
  1. +9 −3 expect.js
12 expect.js
View
@@ -207,11 +207,17 @@
Assertion.prototype.a =
Assertion.prototype.an = function (type) {
if ('string' == typeof type) {
+ // proper english in error msg
+ var n = /^[aeiou]/.test(type) ? 'n' : '';
+
// typeof with support for 'array'
this.assert(
- 'array' == type ? isArray(this.obj) : type == typeof this.obj
- , 'expected ' + i(this.obj) + ' to be a ' + type
- , 'expected ' + i(this.obj) + ' not to be a ' + type);
+ 'array' == type ? isArray(this.obj) :
+ 'object' == type
+ ? 'object' == typeof this.obj && null !== this.obj
+ : type == typeof this.obj
+ , 'expected ' + i(this.obj) + ' to be a' + n + ' ' + type
+ , 'expected ' + i(this.obj) + ' not to be a' + n + ' ' + type);
} else {
// instanceof
var name = type.name || 'supplied constructor';
Please sign in to comment.
Something went wrong with that request. Please try again.