var object = require('../../lib/assert/object');

var should = require('chai').should();

describe('assert.obj', function () {
    describe('lodash', function(){
        var _ = require('lodash');

        it('should implement has', function(){
            var candidate = {
                system: 'READ2',
                code: '6144.',
                display: 'Oral contraceptive repeat'
            };

            var code = {
                system: 'READ2'
            };

            var fn = _.matches(code);
            var result = fn(candidate);

            result.should.equal(true);
        });
    });

    describe('has', function () {
        it('should throw exception if value undefined', function () {
            should.Throw(function () {
                object.has();
            });
        });

        it('should return a function', function () {
            var code = {
                system: 'utest'
            };

            var result = object.has(code);

            should.exist(result);
            result.should.be.a('Function');
        });

        it('should return false when object does not match value', function () {
            var candidate = {
                system: 'READ2',
                code: '6144.',
                display: 'Oral contraceptive repeat'
            };

            var value = {
                system: 'utest'
            };

            var fn = object.has(value);
            var result = fn(candidate);

            should.exist(result);
            result.should.equal(false);
        });

        it('should return true when object matches value', function () {
            var candidate = {
                system: 'READ2',
                code: '6144.',
                display: 'Oral contraceptive repeat'
            };

            var value = {
                system: 'READ2'
            };

            var fn = object.has(value);
            var result = fn(candidate);

            should.exist(result);
            result.should.equal(true);
        });
    });
});