<commit_before>var test = require( 'tape' );
var CarteroNodeHook = require( "../" );
var path = require( "path" );

test( 'throw errors when required options are missing', function( t ) {
	t.plan( 2 );

	t.throws( function() {
		var hook = CarteroNodeHook();
	} );

	t.throws( function() {
		var hook = CarteroNodeHook( '' );
	} );
} );

test( 'example3', function( t ) {
	t.plan( 3 );
	var hook = new CarteroNodeHook(
		path.join( __dirname, "example3/static/assets" ),
		{
			outputDirUrl : "/l"
		}
	);

	hook.getParcelAssets( '/my/fake/abs/path/page1', function( err, result ) {
		if( err ) throw err;

		t.deepEqual( result, {
			script : [ 'b4ca7610c2ace13dc8d4c9f96eb62b459fcfceca/page1_bundle_14d030e0e64ea9a1fced71e9da118cb29caa6676.js' ],
			style : [ 'b4ca7610c2ace13dc8d4c9f96eb62b459fcfceca/page1_bundle_da3d062d2f431a76824e044a5f153520dad4c697.css' ] }
		);
	} );

	hook.getParcelTags( '/my/fake/abs/path/page1', function( err, scriptTags, styleTags ) {
		if( err ) throw err;

		t.deepEqual( scriptTags, '<script type=\'text/javascript\' src=\'/l/b4ca7610c2ace13dc8d4c9f96eb62b459fcfceca/page1_bundle_14d030e0e64ea9a1fced71e9da118cb29caa6676.js\'></script>' );
		t.deepEqual( styleTags, '<link rel=\'stylesheet\' href=\'/l/b4ca7610c2ace13dc8d4c9f96eb62b459fcfceca/page1_bundle_da3d062d2f431a76824e044a5f153520dad4c697.css\'></link>' );
	} );
} );

test( 'example3 (no baseUrl)', function( t ) {

	t.plan( 3 );
	var hook = new CarteroNodeHook(
		path.join( __dirname, "example3/static/assets" )
	);

	hook.getParcelAssets( '/my/fake/abs/path/page2', function( err, result ) {
		if( err ) throw err;

		t.deepEqual( result, {
			script : [ 'ea7138e6b6eea6321eb1926e8ac88d65f16aa51d/page2_bundle_5066f9594b8be17fd6360e23df52ffe750206020.js' ],
			style : [ 'ea7138e6b6eea6321eb1926e8ac88d65f16aa51d/page2_bundle_182694e4a327db0056cfead31f2396287b7d4544.css' ] }
		);
	} );

	hook.getParcelTags( '/my/fake/abs/path/page2', function( err, scriptTags, styleTags ) {
		if( err ) throw err;
	
		t.deepEqual( scriptTags, '<script type=\'text/javascript\' src=\'/ea7138e6b6eea6321eb1926e8ac88d65f16aa51d/page2_bundle_5066f9594b8be17fd6360e23df52ffe750206020.js\'></script>' );
		t.deepEqual( styleTags, '<link rel=\'stylesheet\' href=\'/ea7138e6b6eea6321eb1926e8ac88d65f16aa51d/page2_bundle_182694e4a327db0056cfead31f2396287b7d4544.css\'></link>' );
	} );
} );<commit_msg>added tests for getAssetUrl<commit_after>var test = require( 'tape' );
var CarteroNodeHook = require( "../" );
var path = require( "path" );

test( 'throw errors when required options are missing', function( t ) {
	t.plan( 2 );

	t.throws( function() {
		var hook = CarteroNodeHook();
	} );

	t.throws( function() {
		var hook = CarteroNodeHook( '' );
	} );
} );

test( 'example3', function( t ) {
	t.plan( 4 );

	var hook = new CarteroNodeHook(
		path.join( __dirname, "example3/static/assets" ),
		{
			outputDirUrl : "/l"
		}
	);

	hook.getParcelAssets( '/my/fake/abs/path/page1', function( err, result ) {
		if( err ) throw err;

		t.deepEqual( result, {
			script : [ 'b4ca7610c2ace13dc8d4c9f96eb62b459fcfceca/page1_bundle_14d030e0e64ea9a1fced71e9da118cb29caa6676.js' ],
			style : [ 'b4ca7610c2ace13dc8d4c9f96eb62b459fcfceca/page1_bundle_da3d062d2f431a76824e044a5f153520dad4c697.css' ] }
		);
	} );

	hook.getParcelTags( '/my/fake/abs/path/page1', function( err, scriptTags, styleTags ) {
		if( err ) throw err;

		t.deepEqual( scriptTags, '<script type=\'text/javascript\' src=\'/l/b4ca7610c2ace13dc8d4c9f96eb62b459fcfceca/page1_bundle_14d030e0e64ea9a1fced71e9da118cb29caa6676.js\'></script>' );
		t.deepEqual( styleTags, '<link rel=\'stylesheet\' href=\'/l/b4ca7610c2ace13dc8d4c9f96eb62b459fcfceca/page1_bundle_da3d062d2f431a76824e044a5f153520dad4c697.css\'></link>' );
	} );

	t.deepEqual( hook.getAssetUrl( '/my/fake/abs/path/page1/page1.js' ), '/l/b4ca7610c2ace13dc8d4c9f96eb62b459fcfceca/page1.js' );
} );

test( 'example3 (no baseUrl)', function( t ) {
	t.plan( 4 );

	var hook = new CarteroNodeHook(
		path.join( __dirname, "example3/static/assets" )
	);

	hook.getParcelAssets( '/my/fake/abs/path/page2', function( err, result ) {
		if( err ) throw err;

		t.deepEqual( result, {
			script : [ 'ea7138e6b6eea6321eb1926e8ac88d65f16aa51d/page2_bundle_5066f9594b8be17fd6360e23df52ffe750206020.js' ],
			style : [ 'ea7138e6b6eea6321eb1926e8ac88d65f16aa51d/page2_bundle_182694e4a327db0056cfead31f2396287b7d4544.css' ] }
		);
	} );

	hook.getParcelTags( '/my/fake/abs/path/page2', function( err, scriptTags, styleTags ) {
		if( err ) throw err;
	
		t.deepEqual( scriptTags, '<script type=\'text/javascript\' src=\'/ea7138e6b6eea6321eb1926e8ac88d65f16aa51d/page2_bundle_5066f9594b8be17fd6360e23df52ffe750206020.js\'></script>' );
		t.deepEqual( styleTags, '<link rel=\'stylesheet\' href=\'/ea7138e6b6eea6321eb1926e8ac88d65f16aa51d/page2_bundle_182694e4a327db0056cfead31f2396287b7d4544.css\'></link>' );
	} );

	t.deepEqual( hook.getAssetUrl( '/my/fake/abs/path/page2/page2.js' ), '/ea7138e6b6eea6321eb1926e8ac88d65f16aa51d/page2.js' );
} );
{'fraction_non_alphanumeric': 0.15024875621890546, 'fraction_numerical': 0.16577114427860695, 'mean_word_length': 5.099514563106796, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '6559091', 'n_tokens_mistral': 2670, 'n_tokens_neox': 2209, 'n_words': 277}