{"size": 1200, "ext": "js", "max_stars_repo_path": "jspm_packages/npm/autolinker@0.15.3/tests/UtilSpec.js", "max_stars_repo_name": "jsdelivrbot/project-cms", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "jspm_packages/npm/autolinker@0.15.3/tests/UtilSpec.js", "max_issues_repo_name": "jsdelivrbot/project-cms", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "jspm_packages/npm/autolinker@0.15.3/tests/UtilSpec.js", "max_forks_repo_name": "jsdelivrbot/project-cms", "max_forks_repo_forks_event_min_datetime": "2018-12-09T15:14:03.000Z", "max_forks_repo_forks_event_max_datetime": "2018-12-09T15:14:03.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 36.3636363636, "max_line_length": 142, "alphanum_fraction": 0.6008333333}
/* */ 
"format cjs";
/*global Autolinker, _, describe, beforeEach, afterEach, it, expect */
describe( "Autolinker.Util", function() {
	var Util = Autolinker.Util;
	
	
	describe( 'splitAndCapture()', function() {
		
		it( "should throw an error if the supplied regular expression does not have the `global` flag set", function() {
			expect( function() {
				Util.splitAndCapture( 'test', /,/ );  // note: no 'g' flag
			} ).toThrow( new Error( "`splitRegex` must have the 'g' flag set" ) );
		} );
		
		
		it( "should return an array with the 'split' characters included", function() {
			var result = Util.splitAndCapture( 'a,b,c', /,/g );
			
			expect( result ).toEqual( [ 'a', ',', 'b', ',', 'c' ] );
		} );
		
		
		it( "should return an array with the 'split' characters included, when there are multiple sequences of characters to split on", function() {
			var re = /(&nbsp;|&#160;|&lt;|&#60;|&gt;|&#62;)/g,
			    result = Util.splitAndCapture( 'Joe went to yahoo.com and used HTML&nbsp;entities like &gt; and &lt; today', re );
			
			expect( result ).toEqual( [ 'Joe went to yahoo.com and used HTML', '&nbsp;', 'entities like ', '&gt;', ' and ', '&lt;', ' today' ] );
		} );
		
	} );
	
} );