Skip to content

Commit

Permalink
Add support for non-plain objects
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiebuilds committed Mar 15, 2015
1 parent ba5486c commit 85643d3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/pretty-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,10 @@ Type.Number = new Type({
* @memberOf Type
*/
Type.Object = new Type({
test: _.isPlainObject,
test: _.isObject,

print(val) {
var result = 'Object {',
var result = val.constructor.name + ' {',
keys = _.keys(val),
symbols = getSymbols(val);

Expand Down Expand Up @@ -420,11 +420,12 @@ Type.all = [
Type.NaN,
Type.Null,
Type.Number,
Type.Object,
Type.RegExp,
Type.Set,
Type.String,
Type.Symbol,
Type.Undefined,
Type.Date
Type.Date,

Type.Object
];
9 changes: 7 additions & 2 deletions test/unit/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,19 @@ describe('Type', function() {
}());

(function() {
function Foo() {}
var foo = new Foo();

typeTests('Object', Type.Object, {
test: [
{ value: {}, pass: true },
{ value: new Map(), pass: false },
{ value: [], pass: false }
{ value: foo, pass: true },
{ value: new Map(), pass: true },
{ value: [], pass: true }
],
print: [
{ input: {}, output: 'Object {}' },
{ input: foo, output: 'Foo {}' },
{ input: { foo: 'bar', bar: 'baz' }, output: 'Object {\n "foo": "bar",\n "bar": "baz"\n}' },
{ input: { foo: { bar: 'baz' } }, output: 'Object {\n "foo": Object {\n "bar": "baz"\n }\n}' },
{ input: { [Symbol('foo')]: 'foo' }, output: 'Object {\n Symbol(foo): "foo"\n}' }
Expand Down

0 comments on commit 85643d3

Please sign in to comment.