var assert = require('assert');

var vumigo = require('vumigo_v02');
var BaseError = vumigo.utils.BaseError;

var provider = require('../../lib/providers/provider');
var ProviderNotImplementedError = provider.ProviderNotImplementedError;
var AddressResult = provider.AddressResult;

describe('ProviderNotImplementedError', function() {
    it('should extend BaseError', function() {
        var err = new ProviderNotImplementedError('coming soon');
        assert(err instanceof BaseError);
    });

    it('should have a name', function() {
        var err = new ProviderNotImplementedError('coming soon');
        assert.strictEqual(err.name, 'ProviderNotImplementedError');
    });

    it('should have a message', function() {
        var err = new ProviderNotImplementedError('.foo not implemented');
        assert.strictEqual(err.message, '.foo not implemented');
    });
});

describe('AddressResult', function() {
    it('should have a label', function() {
        var addr = new AddressResult('2b Baker Street', {});
        assert.strictEqual(addr.label, '2b Baker Street');
    });

    it('should contain data', function() {
        var addr = new AddressResult('label', {'custom': 'data'});
        assert.deepEqual(addr.data, {'custom': 'data'});
    });
});

@@ -101,16 +101,94 @@
 seError;
+%0Avar Extendable = vumigo.utils.Extendable;%0Avar test_utils = vumigo.test_utils;
 %0A%0Avar pr
@@ -352,16 +352,50 @@
 sResult;
+%0Avar Provider = provider.Provider;
 %0A%0Adescri
@@ -1306,24 +1306,24 @@
 : 'data'%7D);%0A
-
         asse
@@ -1367,20 +1367,1005 @@
 ata'%7D);%0A    %7D);%0A%7D);%0A
+%0Adescribe('Provider', function() %7B%0A    it('should be extendable', function() %7B%0A        var p = new Provider();%0A        assert(p instanceof Extendable);%0A    %7D);%0A%0A    describe('.init()', function() %7B%0A        it('should have a default implementation', function() %7B%0A            var p = new Provider();%0A            var dummy_im = %7B%7D;%0A            p.init(dummy_im);%0A        %7D);%0A    %7D);%0A%0A    describe('.search()', function() %7B%0A        it('should raise ProviderNotImplementedError', function() %7B%0A            var p = new Provider();%0A            assert.throws(function () %7B%0A                p.search(%22corner of smith and long%22);%0A            %7D, ProviderNotImplementedError);%0A        %7D);%0A%0A        it('should provide a suitable error message', function() %7B%0A            var p = new Provider();%0A            var e = test_utils.catch_err(function() %7B%0A                p.search('the middle of');%0A            %7D);%0A            assert.strictEqual(e.message, '.search not implemented');%0A        %7D);%0A    %7D);%0A%7D);%0A

Add tests for Provider.