1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
/*global Autolinker, _, describe, beforeEach, afterEach, it, expect */
describe( "Autolinker.Util", function() {
var Util = Autolinker.Util;
describe( 'defaults()', function() {
it( 'should not overwrite any properties that exist on the destination object', function() {
var obj = Util.defaults( { a: 1, b: 2, c: 3 }, { a: 91, b: 92, c: 93 } );
expect( obj ).toEqual( { a: 1, b: 2, c: 3 } );
} );
it( 'should add properties that do not exist on the destination object, without overwriting properties that do exist', function() {
var obj = Util.defaults( { b: 2 }, { a: 91, b: 92, c: 93 } );
expect( obj ).toEqual( { a: 91, b: 2, c: 93 } );
} );
} );
describe( 'splitAndCapture()', function() {
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 = /( | |<|<|>|>)/g,
result = Util.splitAndCapture( 'Joe went to yahoo.com and used HTML entities like > and < today', re );
expect( result ).toEqual( [ 'Joe went to yahoo.com and used HTML', ' ', 'entities like ', '>', ' and ', '<', ' today' ] );
} );
} );
} );
|