Solr.spec.js 1.77 KB
define(function(require) {
    'use strict';
    var _ = require('underscore');
    var Backbone = require('backbone');
    var Solr = require('solr/model/Solr');
    var SolrTestData = require('solr/model/Solr.spec.data');

    describe('Solr', function() {
        it('loads', function() {
            expect(Solr).toBeDefined();
        });

        describe('construct', function() {
            var s;
            var origNow;
            var facets;
            var modelFacet, modelItems;
            beforeEach(function() {
                jasmine.clock().install();
                jasmine.clock().mockDate();
                origNow = _.now;
                _.now = function() { return new Date().getTime(); };
                spyOn(Backbone, 'ajax');
                s = new (SolrTestData.testSearchBuilder())();
                facets = s.get('facets');
                modelFacet = facets.get('model');
                modelItems = modelFacet.get('items');
            });
            afterEach(function() {
                jasmine.clock().uninstall();
                _.now = origNow;
            });
            it('initial values', function() {
                expect(Backbone.ajax).not.toHaveBeenCalled();
                expect(modelItems.length).toBe(0);
            });
            describe('initial debounce', function() {
                beforeEach(function() {
                    jasmine.clock().tick(300);
                });
                it('foo', function() {
                    expect(Backbone.ajax).not.toHaveBeenCalled();
                });
            });
            describe('click facet', function() {
                beforeEach(function() {
                });
                it('not searched', function() {
                });
            });
        });
    });
});