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

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

describe('assert.extension', function () {
    describe('hasUrl', function () {
        it('should throw exception if value undefined', function () {
            should.Throw(function () {
                extension.hasUrl();
            });
        });

        it('should return a function', function () {
            var url = 'http://foo.com/bar';

            var result = extension.hasUrl(url);

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

        it('should return false when object does not match value', function () {
            var candidate = {
                url: 'http://test.com/nomatch'
            };

            var fn = extension.hasUrl('http://foo.com/bar');
            var result = fn(candidate);

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

        it('should return true when object matches value', function () {
            var candidate = {
                url: 'http://foo.com/bar'
            };

            var fn = extension.hasUrl('http://foo.com/bar');
            var result = fn(candidate);

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