Better testing of field name format

pull/2/head
Louis Chatriot 12 years ago
parent ab6962b1b8
commit c716261271
  1. 20
      test/model.test.js

@ -109,16 +109,20 @@ describe('Model', function () {
c.test[2].again.should.equal('yes'); c.test[2].again.should.equal('yes');
}); });
it('Reject field names beginning with a $ sign', function (done) { it('Reject field names beginning with a $ sign or containing a dot, except the two edge cases', function () {
var a = { $something: 'totest' } var a1 = { $something: 'totest' }
, a2 = { "with.dot": 'totest' }
, e1 = { $$date: 4321 }
, e2 = { $$deleted: true }
, b; , b;
try { // Normal cases
b = model.serialize(a); (function () { b = model.serialize(a1); }).should.throw();
return done('An error should have been thrown'); (function () { b = model.serialize(a2); }).should.throw();
} catch (e) {
return done(); // Edge cases
} b = model.serialize(e1);
b = model.serialize(e2);
}); });
}); // ==== End of 'Serialization, deserialization' ==== // }); // ==== End of 'Serialization, deserialization' ==== //

Loading…
Cancel
Save