<commit_before>var karyoFile = "data/karyo.json";

if(navigator.userAgent.match(/phantomjs/i)){	
	karyoFile = "https://raw.githubusercontent.com/BioInf-Wuerzburg/wgaPipeline/d3.js/d3_test/data/karyo.json";
};

describe("test the verification of the karyofile", function() {
	it("karyo file should be defined", function() {
		var file = "data/karyo.json";
		expect(file).toBeDefined();
	});
	it("the karyo file in the function should be defined", function() {
		expect(loadKaryoFile(karyoFile)).toBeDefined();
	});

});


describe(
		
		"loadKaryoFile",
		function() {
			var returnData;
			var expectedChromosomes = {
				"Q_s6" : {
					"genome_id" : 1,
					"rc" : false,
					"length" : 416406,
					"seq" : null
				},
				"Q_s8" : {
					"length" : 257437,
					"genome_id" : 1,
					"rc" : false,
					"seq" : null
				},
				"R_gi_222106127_ref_NC_011988.1_" : {
					"length" : 1283187,
					"rc" : false,
					"genome_id" : 0,
					"seq" : null
				},
				"Q_s2" : {
					"seq" : null,
					"length" : 531783,
					"rc" : false,
					"genome_id" : 1
				},
				"Q_s22" : {
					"length" : 117247,
					"genome_id" : 1,
					"rc" : false,
					"seq" : null
				}
			};
			var expectedOrder = [ "R_gi_222106127_ref_NC_011988.1_", "Q_s6",
					"Q_s8", "Q_s22", "Q_s2" ];

			beforeEach(function(done) {
				loadKaryoFile(karyoFile, function(data) {
					returnData = data;
					done();
				});
			});

			it(
					"the external karyo file should be load in and we have the chromosome object",
					function() {
						expect(returnData.chromosomes).toEqual(
								expectedChromosomes);
					});

			it(
					"the external karyo file should be load in and we have the order array",
					function() {
						expect(returnData.order).toEqual(expectedOrder);
					});
			


		});

describe("Spy on loadKaryo", function(){
	var loadKaryo = {};
	loadKaryo.test = function test(karyoFile){
		loadKaryoFile(karyoFile);
	}
	
	beforeEach(function() {
		spyOn(loadKaryo, 'test');
	    loadKaryo.test(karyoFile);
	});
	
	it("tracks that the spy was called", function() {
	    expect(loadKaryo.test).toHaveBeenCalled();
	});
	
	it("tracks all the arguments of its calls", function() {
		if(navigator.userAgent.match(/phantomjs/i)){	
			expect(loadKaryo.test).toHaveBeenCalledWith("https://raw.githubusercontent.com/BioInf-Wuerzburg/wgaPipeline/d3.js/d3_test/data/karyo.json");
		}
		else{
			expect(loadKaryo.test).toHaveBeenCalledWith("data/karyo.json");
		}
	    
	});

})<commit_msg>testbeschreibung für spyOn loadKaryoFile erweitert<commit_after>var karyoFile = "data/karyo.json";

if(navigator.userAgent.match(/phantomjs/i)){	
	karyoFile = "https://raw.githubusercontent.com/BioInf-Wuerzburg/wgaPipeline/d3.js/d3_test/data/karyo.json";
};

describe("test the verification of the karyofile", function() {
	it("karyo file should be defined", function() {
		var file = "data/karyo.json";
		expect(file).toBeDefined();
	});
	it("the karyo file in the function should be defined", function() {
		expect(loadKaryoFile(karyoFile)).toBeDefined();
	});

});


describe(
		
		"loadKaryoFile",
		function() {
			var returnData;
			var expectedChromosomes = {
				"Q_s6" : {
					"genome_id" : 1,
					"rc" : false,
					"length" : 416406,
					"seq" : null
				},
				"Q_s8" : {
					"length" : 257437,
					"genome_id" : 1,
					"rc" : false,
					"seq" : null
				},
				"R_gi_222106127_ref_NC_011988.1_" : {
					"length" : 1283187,
					"rc" : false,
					"genome_id" : 0,
					"seq" : null
				},
				"Q_s2" : {
					"seq" : null,
					"length" : 531783,
					"rc" : false,
					"genome_id" : 1
				},
				"Q_s22" : {
					"length" : 117247,
					"genome_id" : 1,
					"rc" : false,
					"seq" : null
				}
			};
			var expectedOrder = [ "R_gi_222106127_ref_NC_011988.1_", "Q_s6",
					"Q_s8", "Q_s22", "Q_s2" ];

			beforeEach(function(done) {
				loadKaryoFile(karyoFile, function(data) {
					returnData = data;
					done();
				});
			});

			it(
					"the external karyo file should be load in and we have the chromosome object",
					function() {
						expect(returnData.chromosomes).toEqual(
								expectedChromosomes);
					});

			it(
					"the external karyo file should be load in and we have the order array",
					function() {
						expect(returnData.order).toEqual(expectedOrder);
					});
			


		});

describe("Spy on loadKaryoFile", function(){
	//es wird ein test-Objekt loadKaryo angelegt, welches als test-Eigenschaft den Aufruf auf die Funktion loadKaryoFile enthält
	var loadKaryo = {};
	loadKaryo.test = function test(karyoFile){
		loadKaryoFile(karyoFile);
	}
	
	//vor jedem spec wird der spy auf loadKaryo gesetzt
	beforeEach(function() {
		spyOn(loadKaryo, 'test');
	    loadKaryo.test(karyoFile);
	});
	
	
	it("the spy tracks that the function loadKaryoFile was called", function() {
	    expect(loadKaryo.test).toHaveBeenCalled();
	});
	
	it("the spy tracks the arguments of loadKaryoFile. In this case the arguments are either the filename or when you use grunt the url to the github-page. " +
			"The test fails when you not assign the access to the data", function() {
		if(navigator.userAgent.match(/phantomjs/i)){	
			expect(loadKaryo.test).toHaveBeenCalledWith("https://raw.githubusercontent.com/BioInf-Wuerzburg/wgaPipeline/d3.js/d3_test/data/karyo.json");
		}
		else{
			expect(loadKaryo.test).toHaveBeenCalledWith("data/karyo.json");
		}
	    
	});

})
{'fraction_non_alphanumeric': 0.1484302433587219, 'fraction_numerical': 0.030466282741965448, 'mean_word_length': 3.060331825037707, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '1535973', 'n_tokens_mistral': 2598, 'n_tokens_neox': 2025, 'n_words': 399}