Skip to content

Commit

Permalink
Added json test
Browse files Browse the repository at this point in the history
  • Loading branch information
1602 committed Mar 19, 2013
1 parent ab392a4 commit aad21e9
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/json.test.js
@@ -0,0 +1,36 @@
var Schema = require('jugglingdb').Schema;
var should = require('should');

describe('JSON property', function() {
var schema, Model;

it('could be defined', function() {
schema = new Schema('memory');
Model = schema.define('Model', {propertyName: Schema.JSON});
var m = new Model;
m.should.have.property('propertyName');
should.not.exist(m.propertyName);
});

it('should accept JSON in constructor and return object', function() {
var m = new Model({
propertyName: '{"foo": "bar"}'
});
m.propertyName.should.be.an.Object;
m.propertyName.foo.should.equal('bar');
});

it('should accept object in setter and return object', function() {
var m = new Model;
m.propertyName = {"foo": "bar"};
m.propertyName.should.be.an.Object;
m.propertyName.foo.should.equal('bar');
});

it('should accept string in setter and return string', function() {
var m = new Model;
m.propertyName = '{"foo": "bar"}';
m.propertyName.should.be.a.String;
m.propertyName.should.equal('{"foo": "bar"}');
});
});

0 comments on commit aad21e9

Please sign in to comment.