define([
    'jquery',
    'lodash',
    'Squire',
    'bitbucket/internal/util/object',
    // These deps are required but not needed in this test.
    'test-helper',
    'bitbucket/internal/bbui/javascript-errors/javascript-errors',
    'bitbucket/internal/bbui/json-validation/json-validation',
    'bitbucket/internal/bbui/widget/widget'
], function (
    $,
    _,
    Squire,
    obj
) {


    var mockResponse = { values: 123 };
    var mockServer = {
        rest : sinon.spy(function() {
            var promise = $.Deferred();
            promise.abort = $.noop;
            return promise.resolve(mockResponse);
        })
    };
    var injector = new Squire();
    injector.setDefaultDeps(['bitbucket/internal/impl/data-provider/data-provider']);
    injector.mock('bitbucket/util/server', mockServer);

    QUnit.module('data-provider');

    var makeProvider = _.once(function (DataProvider) {
        // implement a very basic data provider for tests
        function ImplementedProvider () {
            DataProvider.apply(this, arguments);
        }

        obj.inherits(ImplementedProvider, DataProvider);

        ImplementedProvider.prototype._transform = function (data) {
            return data;
        };

        ImplementedProvider.prototype._validate = sinon.spy();

        return ImplementedProvider;
    });

    injector.test('implemented _fetch is used to return data', function (assert, DataProvider) {
        var ImplementedProvider = makeProvider(DataProvider);
        var provider = new ImplementedProvider();
        var done = assert.async();
        provider
            .fetch('http://foo')
            .done(function (data) {
                      assert.deepEqual(data, mockResponse, 'fetch returns data from the implemented _fetch');
                      done();
                  });
    });
});
