Skip to content
This repository has been archived by the owner on Dec 1, 2018. It is now read-only.

Commit

Permalink
Added test for patternProperties.
Browse files Browse the repository at this point in the history
  • Loading branch information
pluma committed Jan 14, 2014
1 parent 14074cf commit ca3c067
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion index.js
@@ -1,4 +1,4 @@
/*! revalidator-model 0.2.1 Original author Alan Plum <me@pluma.io>. Released into the Public Domain under the UNLICENSE. @preserve */
/*! revalidator-model 0.2.2 Original author Alan Plum <me@pluma.io>. Released into the Public Domain under the UNLICENSE. @preserve */
var revalidator = require('revalidator'),
filterObj = require('object-filter'),
transform = require('transform-object'),
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "revalidator-model",
"version": "0.2.1",
"version": "0.2.2",
"author": "Alan Plum <me@pluma.io>",
"description": "Simple validatable models with revalidator.",
"licenses": {
Expand Down
14 changes: 13 additions & 1 deletion spec/model.spec.js
Expand Up @@ -53,7 +53,10 @@ describe('Model.hydrate(data)', function() {
});

describe('new Model(data)', function() {
var Model = model({properties: {foo: true, bar: true}});
var Model = model({
properties: {foo: true, bar: true},
patternProperties: {'^f0[01]$': true}
});
it('returns a Model instance', function() {
var obj = Model({});
expect(obj).to.be.a(Model);
Expand All @@ -67,6 +70,15 @@ describe('new Model(data)', function() {
expect(obj.data).to.have.property('bar');
expect(obj.data.bar).to.equal('b');
});
it('copies pattern matching attributes', function() {
var obj = Model({f00: 'a', f01: 'b', f000: 'c'});
expect(obj).to.have.property('data');
expect(obj.data).to.have.property('f00');
expect(obj.data.f00).to.equal('a');
expect(obj.data).to.have.property('f01');
expect(obj.data.f01).to.equal('b');
expect(obj.data).to.not.have.property('f000');
});
it('does not simply copy the data object', function() {
var data = {};
var obj = Model(data);
Expand Down

0 comments on commit ca3c067

Please sign in to comment.