Browse files

Adding readonly schema property

  • Loading branch information...
1 parent 753f492 commit 48aecad70b6515ce49ab72265ddeb8becb07cb43 @serby committed Aug 15, 2012
Showing with 20 additions and 6 deletions.
  1. +4 −6 lib/schemata.js
  2. +16 −0 test/schemata.test.js
View
10 lib/schemata.js
@@ -11,11 +11,7 @@ function ArrayType(schema) {
module.exports = function(schema) {
// Start with a blank scheme to reduce error checking
- if (schema === undefined) {
- schema = {};
- } else {
- schema = schema;
- }
+ schema = schema || {};
/**
* Returns a new object with properties and default values from the schema definition.
@@ -300,7 +296,9 @@ module.exports = function(schema) {
}
return {
- schema: schema,
+ get schema() {
+ return schema;
+ },
makeDefault: makeDefault,
makeBlank: makeBlank,
hasTag: hasTag,
View
16 test/schemata.test.js
@@ -102,6 +102,22 @@ var typeMap = {
describe('schemata', function() {
+ describe('#schema', function() {
+
+ it('schema should be empty for a default schemata', function() {
+ var empty = schemata();
+ empty.schema.should.eql({});
+ });
+
+ it('schema should be read only', function() {
+ var empty = schemata();
+ empty.schema = { write: 'me' };
+ empty.schema.should.eql({});
+ });
+
+
+ });
+
describe('#makeBlank()', function() {
it('returns correct empty object with no parameters', function() {

0 comments on commit 48aecad

Please sign in to comment.