<commit_before>/* jslint browser:true */
/* global define */
/* global describe, beforeEach, jasmine, afterEach, spyOn, it, expect */

define([
	'squire',
	'jquery',
	'select2',
	'backbone'
], function(Squire, $, select2, Backbone) {
	"use strict";

	describe('SearchFilterRowView', function() {
		var SearchFilterRowView, testView, testModel;
		var fetchPubTypeSpy, fetchPubTypeDeferred;
		var injector;
		var $testDiv;

		beforeEach(function (done) {
			injector = new Squire();

			$('body').append('<div id="test-div"></div>');
			$testDiv = $('#test-div');
			testModel = new Backbone.Model();

			fetchPubTypeDeferred = $.Deferred();
			fetchPubTypeSpy = jasmine.createSpy('fetchPubTypeSpy').and.returnValue(fetchPubTypeDeferred);

			injector.mock('models/PublicationTypeCollection', Backbone.Collection.extend({
				fetch: fetchPubTypeSpy,
				toJSON : function() {
					return [{id : 1, text : 'Type1'}, {id : 2, text : 'Type2'}, {id : 3, text : 'Type3'}];
				}
			}));

			spyOn($.fn, 'select2').and.callThrough();
			injector.mock('jquery', $); // Needed to spy on select2 initialization.

			injector.require(['views/SearchFilterRowView'], function (view) {
				SearchFilterRowView = view;
				done();<commit_msg>Updated the SearchFilterRowView tests to mock out Cost Center collection fetch.<commit_after>/* jslint browser:true */
/* global define */
/* global describe, beforeEach, jasmine, afterEach, spyOn, it, expect */

define([
	'squire',
	'jquery',
	'select2',
	'backbone'
], function(Squire, $, select2, Backbone) {
	"use strict";

	describe('SearchFilterRowView', function() {
		var SearchFilterRowView, testView, testModel;
		var fetchPubTypeSpy, fetchPubTypeDeferred;
		var costCenterFetchSpy, costCenterFetchActiveDeferred, costCenterFetchNotActiveDeferred
		var injector;
		var $testDiv;

		beforeEach(function (done) {
			injector = new Squire();

			$('body').append('<div id="test-div"></div>');
			$testDiv = $('#test-div');
			testModel = new Backbone.Model();

			fetchPubTypeDeferred = $.Deferred();
			fetchPubTypeSpy = jasmine.createSpy('fetchPubTypeSpy').and.returnValue(fetchPubTypeDeferred);

			costCenterFetchSpy = jasmine.createSpy('costCenterFetchSpy').and.callFake(function(options) {
				if (options.data.active === 'y') {
					return costCenterFetchActiveDeferred;
				}
				else {
					return costCenterFetchNotActiveDeferred;
				}
			});

			injector.mock('models/PublicationTypeCollection', Backbone.Collection.extend({
				fetch: fetchPubTypeSpy,
				toJSON : function() {
					return [{id : 1, text : 'Type1'}, {id : 2, text : 'Type2'}, {id : 3, text : 'Type3'}];
				}
			}));
			injector.mock('models/CostCenterCollection', Backbone.Collection.extend({
				url : '/test/lookup',
				fetch : costCenterFetchSpy
			}));

			spyOn($.fn, 'select2').and.callThrough();
			injector.mock('jquery', $); // Needed to spy on select2 initialization.

			injector.require(['views/SearchFilterRowView'], function (view) {
				SearchFilterRowView = view;
				done();
{'fraction_non_alphanumeric': 0.15635395874916833, 'fraction_numerical': 0.00665335994677312, 'mean_word_length': 4.457350272232305, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '669677', 'n_tokens_mistral': 1117, 'n_tokens_neox': 951, 'n_words': 201}