/* jshint expr: true */

var model = require('../mocks/model');
var schema = require('./index')(model);
var should = require('should');
var atf = require('../specs/atf');
var util = require('util');

describe('Properties Schema', function() {
    'use strict';

    it('should require a name', function() {
        let p = {
            value: 4,
            units: 'mm',
            _type: 'number',
            measurement_id: 'id'
        };

        let errors = schema.properties.validateSync(p);
        should.exist(errors);
        errors.should.have.ownProperty('name');
    });

    it('should validate the type', function() {
        let p = {
            name: 'name',
            value: 4,
            units: 'mm',
            measurement_id: 'id',
            _type: 'does-not-exist'
        };
        let errors = schema.properties.validateSync(p);
        should.exist(errors);
        errors.should.have.key('_type');
    });

    it('should pass for a valid object', function() {
        let p = {
            name: 'name',
            value: 4,
            units: 'mm',
            measurement_id: 'id',
            _type: 'number'
        };

        let errors = schema.properties.validateSync(p);
        should.not.exist(errors);
    });
});

@@ -1254,13 +1254,245 @@
 %0A    %7D);
+%0A%0A    it('should only validate name and ignore other fields', function() %7B%0A        let p = %7B%0A            name: 'name'%0A        %7D;%0A%0A        let errors = schema.properties.validateSync(p, true);%0A        should.not.exist(errors);%0A    %7D)
 %0A%7D);%0A

Test ignoring missing fields.