1602 / jugglingdb

Multi-database ORM for nodejs: redis, mongodb, mysql, sqlite3, postgresql, arango, in-memory...
http://1602.github.io/jugglingdb/
2.05k stars 241 forks source link

Models appear to be returning Booleans as objects, not Booleans #369

Closed mshick closed 10 years ago

mshick commented 10 years ago

I've been working on a test for my PR and noticed that Booleans are not working as expected. Working with the datatype.test.js, I see that the testFind() and testAll() functions are returning models with prop 'bool' = {}. Checking typeof(m.bool) yields "object".

Strangely, the mocha test is not catching this, even though I am capable of making mocha trigger an error with, for instance

var obj = {};
typeof(obj) // -----> 'obect'
obj.should.be.a.Boolean;

---> AssertionError: expected {} to be a boolean

But this isn't triggering an error as I'd expect:

typeof(m.bool); // ----> 'object'
m.bool.should.be.a.Boolean;
mshick commented 10 years ago

Ugh, sorry, new to mocha. I just realized this seems to be a side-effect of logging in the testing environment.

pocesar commented 10 years ago

@mshick I'm having the same problem with mocha, what is the recommended fix / workaround? I don't seem to be able to use expect(obj).to.eql(model), since it's showing the boolean as {}