From c7162612714e3a369e85a64afd12c7fb2ad7e75f Mon Sep 17 00:00:00 2001 From: Louis Chatriot Date: Sat, 25 May 2013 12:43:39 +0200 Subject: [PATCH] Better testing of field name format --- test/model.test.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/test/model.test.js b/test/model.test.js index a1422ed..4ee42c0 100644 --- a/test/model.test.js +++ b/test/model.test.js @@ -109,16 +109,20 @@ describe('Model', function () { c.test[2].again.should.equal('yes'); }); - it('Reject field names beginning with a $ sign', function (done) { - var a = { $something: 'totest' } + it('Reject field names beginning with a $ sign or containing a dot, except the two edge cases', function () { + var a1 = { $something: 'totest' } + , a2 = { "with.dot": 'totest' } + , e1 = { $$date: 4321 } + , e2 = { $$deleted: true } , b; - try { - b = model.serialize(a); - return done('An error should have been thrown'); - } catch (e) { - return done(); - } + // Normal cases + (function () { b = model.serialize(a1); }).should.throw(); + (function () { b = model.serialize(a2); }).should.throw(); + + // Edge cases + b = model.serialize(e1); + b = model.serialize(e2); }); }); // ==== End of 'Serialization, deserialization' ==== //