<commit_before>var path = require( 'path' );
var constructor = require( path.join('..', 'lib', 'directory-encoder'));
var fs = require('fs');

"use strict";
var encoder, output = "test/output/encoded.css";

exports['encode'] = {
	setUp: function( done ) {
		encoder = new constructor( "test/encoding", output );
		done();
	},

	output: function( test ) {
		encoder.encode();
		test.ok( fs.existsSync(output) );
		test.ok( /\.bear/.test(fs.readFileSync(output)) );
		test.done();
	},

	selector: function( test ) {
		encoder._css = function( name, data ){
			test.ok( name === "bear" || name === "dog" );

			return constructor.prototype._css(name, data);
		};

		encoder.encode();
		test.done();
	},

	dup: function( test ) {
		encoder = new constructor( "test/encoding-dup", output );
		test.throws(function() { encoder.encode(); });
		test.done();
	}
};

var svg = constructor.encoders.svg,
  png = constructor.encoders.png;

exports['encoderSelection'] = {
	setUp: function( done ) {
		encoder = new constructor( "test/encoding", output );
		done();
	},

  tearDown: function( done ) {
    svg = constructor.encoders.svg;
    png = constructor.encoders.png;
    done();
  },

	handler: function( test ) {
    constructor.encoders.svg = function(){};
    constructor.encoders.svg.prototype.encode = function() {
      return "foo";
    };

    constructor.encoders.png = function(){};
    constructor.encoders.png.prototype.encode = function() {
      return "bar";
    };

    encoder._css= function( filename, datauri ) {
      test.ok( datauri === "foo" || datauri === "bar" );
    };

		encoder.encode();

		test.done();
	}
};


exports['css'] = {
	setUp: function( done ) {
		encoder = new constructor( "test/encoding", "test/output/encoded.css" );
		encoder2 = new constructor( "test/encoding", "test/output/encoded2.css",
															{ template: "test/files/default-css.hbs"} );
		encoder3 = new constructor( "test/encoding", "test/output/encoded3.css",
															{
																template: "test/files/default-css.hbs",
																customselectors: {
																	"foo": ["icon-2"]
																}
															} );
		done();
	},

	rule: function( test ) {
		test.equal( encoder._css("foo", "bar"),
			".foo { background-image: url('bar'); background-repeat: no-repeat; }" );
		test.done();
	},
<commit_msg>fix for proto change leak<commit_after>var path = require( 'path' );
var constructor = require( path.join('..', 'lib', 'directory-encoder') );
var SvgURIEncoder = require( path.join('..', 'lib', 'svg-uri-encoder') );
var PngURIEncoder = require( path.join('..', 'lib', 'png-uri-encoder') );
var fs = require('fs');

"use strict";
var encoder, output = "test/output/encoded.css";

exports['encode'] = {
	setUp: function( done ) {
		encoder = new constructor( "test/encoding", output );
		done();
	},

	output: function( test ) {
		encoder.encode();
		test.ok( fs.existsSync(output) );
		test.ok( /\.bear/.test(fs.readFileSync(output)) );
		test.done();
	},

	selector: function( test ) {
		encoder._css = function( name, data ){
			test.ok( name === "bear" || name === "dog" );

			return constructor.prototype._css(name, data);
		};

		encoder.encode();
		test.done();
	},

	dup: function( test ) {
		encoder = new constructor( "test/encoding-dup", output );
		test.throws(function() { encoder.encode(); });
		test.done();
	}
};

exports['encoderSelection'] = {
	setUp: function( done ) {
		encoder = new constructor( "test/encoding", output );
		done();
	},

	tearDown: function( done ) {
		constructor.encoders = {
			svg: SvgURIEncoder,
			png: PngURIEncoder
		};

		done();
	},

	handler: function( test ) {
		constructor.encoders.svg = function(){};
		constructor.encoders.svg.prototype.encode = function() {
			return "foo";
		};

		constructor.encoders.png = function(){};
		constructor.encoders.png.prototype.encode = function() {
			return "bar";
		};

		encoder._css = function( filename, datauri ) {
			test.ok( datauri === "foo" || datauri === "bar" );
		};

		encoder.encode();

		test.done();
	}
};


exports['css'] = {
	setUp: function( done ) {
		encoder = new constructor( "test/encoding", "test/output/encoded.css" );
		encoder2 = new constructor( "test/encoding", "test/output/encoded2.css",
															{ template: "test/files/default-css.hbs"} );
		encoder3 = new constructor( "test/encoding", "test/output/encoded3.css",
															{
																template: "test/files/default-css.hbs",
																customselectors: {
																	"foo": ["icon-2"]
																}
															} );
		done();
	},

	rule: function( test ) {
		test.equal( encoder._css("foo", "bar"),
			".foo { background-image: url('bar'); background-repeat: no-repeat; }" );
		test.done();
	},

{'fraction_non_alphanumeric': 0.1884485666104553, 'fraction_numerical': 0.0021079258010118043, 'mean_word_length': 3.0211864406779663, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, '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': '2852461', 'n_tokens_mistral': 1850, 'n_tokens_neox': 1546, 'n_words': 320}