<commit_before>steal("can/util/fixture", "can/model",'funcunit/qunit', function(){

module("can/util/fixture");

test("static fixtures", function(){
	stop();
	
	can.fixture("GET something", "//can/util/fixture/fixtures/test.json");
	can.fixture("POST something", "//can/util/fixture/fixtures/test.json");

	can.ajax({
		url : 'something',
		dataType : 'json'
	}).done(function(data) {
		equals(data.sweet,"ness","can.get works");
		can.ajax({
			url : 'something',
			method : 'POST',
			dataType : 'json'
		}).done(function(data) {
			equals(data.sweet,"ness","can.post works");
			start();
		});
		start();
	});
})

test("dynamic fixtures",function(){
	stop();
	can.fixture.delay = 10;
	can.fixture("something", function(){
		return [{sweet: "ness"}]
	});

	can.ajax({
		url : 'something',
		dataType : 'json'
	}).done(function(data) {
		equals(data.sweet,"ness","can.get works");
		start();	
	});
});

test("fixture function", 3, function(){
	stop();
	var url = steal.root.join("can/util/fixture/fixtures/foo.json")+'';
	can.fixture(url,"//can/util/fixture/fixtures/foobar.json" );

	can.ajax({
		url : url,
		dataType : 'json'
	}).done(function(data){
		equals(data.sweet,"ner","url passed works");
		can.fixture(url,"//can/util/fixture/fixtures/test.json" );

		can.ajax({
			url : url,
			dataType : 'json'
		}).done(function(data){
			equals(data.sweet,"ness","replaced");
			can.fixture(url, null );

			can.ajax({
				url : url,
				dataType : 'json'
			}).done(function(data){
				equals(data.a,"b","removed");
				start();
			})
		});
	});
});

if(typeof STEALJQUERY !== 'undefined') {
	// Converters only work with jQuery
	test("fixtures with converters", function(){
		stop();
		can.ajax( {
		  url : steal.root.join("can/util/fixture/fixtures/foobar.json")+'',
		  dataType: "json fooBar",
		  converters: {
		    "json fooBar": function( data ) {
		      // Extract relevant text from the xml document
		      return "Mr. "+data.name;
		    }<commit_msg>jQuery specific test<commit_after>steal("can/util/fixture", "can/model",'funcunit/qunit', function(){

module("can/util/fixture");

test("static fixtures", function(){
	stop();
	
	can.fixture("GET something", "//can/util/fixture/fixtures/test.json");
	can.fixture("POST something", "//can/util/fixture/fixtures/test.json");

	can.ajax({
		url : 'something',
		dataType : 'json'
	}).done(function(data) {
		equals(data.sweet,"ness","can.get works");
		can.ajax({
			url : 'something',
			method : 'POST',
			dataType : 'json'
		}).done(function(data) {
			equals(data.sweet,"ness","can.post works");
			start();
		});
		start();
	});
})

test("dynamic fixtures",function(){
	stop();
	can.fixture.delay = 10;
	can.fixture("something", function(){
		return [{sweet: "ness"}]
	});

	can.ajax({
		url : 'something',
		dataType : 'json'
	}).done(function(data) {
		equals(data.sweet,"ness","can.get works");
		start();	
	});
});

test("fixture function", 3, function(){
	stop();
	var url = steal.root.join("can/util/fixture/fixtures/foo.json")+'';
	can.fixture(url,"//can/util/fixture/fixtures/foobar.json" );

	can.ajax({
		url : url,
		dataType : 'json'
	}).done(function(data){
		equals(data.sweet,"ner","url passed works");
		can.fixture(url,"//can/util/fixture/fixtures/test.json" );

		can.ajax({
			url : url,
			dataType : 'json'
		}).done(function(data){
			equals(data.sweet,"ness","replaced");
			can.fixture(url, null );

			can.ajax({
				url : url,
				dataType : 'json'
			}).done(function(data){
				equals(data.a,"b","removed");
				start();
			})
		});
	});
});

// Converters only work with jQuery
if(typeof jQuery !== 'undefined') {
	test("fixtures with converters", function(){
		stop();
		can.ajax( {
		  url : steal.root.join("can/util/fixture/fixtures/foobar.json")+'',
		  dataType: "json fooBar",
		  converters: {
		    "json fooBar": function( data ) {
		      // Extract relevant text from the xml document
		      return "Mr. "+data.name;
		    }
{'fraction_non_alphanumeric': 0.21375983752221375, 'fraction_numerical': 0.0015232292460015233, 'mean_word_length': 3.735576923076923, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '7561950', 'n_tokens_mistral': 1584, 'n_tokens_neox': 1404, 'n_words': 248}