Comparing version 0.2.2 to 0.2.3
@@ -8,4 +8,15 @@ { | ||
"description" : "n8iv is a functional programming library – for modern javascript engines – which correctly extends JavaScript Natives. Giving you a – relatively – safe and easy to use API, to make your code more succinct and efficient.", | ||
"dependencies" : { "m8" : ">= 0.1.0" }, | ||
"devDependencies" : { "Templ8" : ">= 0.3.0", "mkdirp" : ">= 0.3.0", "mocha" : ">= 1.3.0", "uglify-js" : ">= 1.2.5" }, | ||
"dependencies" : { | ||
"m8" : ">= 0.1.0" | ||
}, | ||
"devDependencies" : { | ||
"Templ8" : ">= 0.3.0", | ||
"chai" : ">= 1.2.0", | ||
"mkdirp" : ">= 0.3.0", | ||
"mocha" : ">= 1.3.0", | ||
"uglify-js" : ">= 1.2.5" | ||
}, | ||
"engines" : { | ||
"node" : ">= 0.4.x" | ||
}, | ||
"keywords" : ["api", "framework", "functional", "javascript", "library", "programming"], | ||
@@ -16,3 +27,3 @@ "licenses" : [ { | ||
} ], | ||
"main" : "./n8iv.js", | ||
"main" : "./n8iv", | ||
"name" : "n8iv", | ||
@@ -24,6 +35,5 @@ "repository" : { | ||
"scripts" : { | ||
"rebuild" : "node ./build.js", | ||
"test" : "mocha -c --globals mocha,expect,m8,n8iv -R spec -s 275 -u tdd ./test" | ||
"test" : "mocha -c --ignore-leaks -R spec -s 275 -u tdd ./test/Array.test.js ./test/Function.test.js ./test/Number.test.js ./test/Object.test.js ./test/String.test.js" | ||
}, | ||
"version" : "0.2.2" | ||
"version" : "0.2.3" | ||
} |
@@ -1,9 +0,11 @@ | ||
typeof m8 !== 'undefined' || ( m8 = require( 'm8' ) ); | ||
typeof n8iv !== 'undefined' || ( n8iv = require( 'n8iv' ) ); | ||
typeof expect !== 'undefined' || ( expect = require( 'expect.js' ) ); | ||
typeof m8 !== 'undefined' || ( m8 = require( 'm8' ) ); | ||
typeof n8iv !== 'undefined' || ( n8iv = require( 'n8iv' ) ); | ||
typeof chai !== 'undefined' || ( chai = require( 'chai' ) ); | ||
expect = chai.expect; | ||
suite( 'Array', function() { | ||
test( 'aggregate', function( done ) { | ||
expect( [1, 2, 3, 4, 5].aggregate( 0, function ( v, n ) { return v += n; } ) ).to.eql( 15 ); | ||
expect( [1, 2, 3, 4, 5].aggregate( 0, function ( v, n ) { return v += n + this; }, 10 ) ).to.eql( 65 ); | ||
expect( [1, 2, 3, 4, 5].aggregate( 0, function ( v, n ) { return v += n; } ) ).to.deep.equal( 15 ); | ||
expect( [1, 2, 3, 4, 5].aggregate( 0, function ( v, n ) { return v += n + this; }, 10 ) ).to.deep.equal( 65 ); | ||
@@ -19,5 +21,5 @@ done(); | ||
expect( returned ).to.be.an( 'object' ); | ||
expect( returned ).to.eql( expected ); | ||
expect( values.associate( keys, function( v ) { return this + v.pad( 2 ); }, 'VALUE_' ) ).to.eql( { 'one' : 'VALUE_01', 'two' : 'VALUE_02', 'three' : 'VALUE_03' } ); | ||
expect( returned ).to.be.an( 'object' ); | ||
expect( returned ).to.deep.equal( expected ); | ||
expect( values.associate( keys, function( v ) { return this + v.pad( 2 ); }, 'VALUE_' ) ).to.deep.equal( { 'one' : 'VALUE_01', 'two' : 'VALUE_02', 'three' : 'VALUE_03' } ); | ||
@@ -28,4 +30,4 @@ done(); | ||
test( 'clear', function( done ) { | ||
expect( [1, 2, 3, 4, 5].clear() ).to.eql( [] ); | ||
expect( [1, 2, 3, 4, 5].clear().length ).to.eql( 0 ); | ||
expect( [1, 2, 3, 4, 5].clear() ).to.deep.equal( [] ); | ||
expect( [1, 2, 3, 4, 5].clear().length ).to.deep.equal( 0 ); | ||
@@ -38,4 +40,4 @@ done(); | ||
expect( a ).not.to.be( [1, 2, 3, 4, 5] ); | ||
expect( a ).to.eql( [1, 2, 3, 4, 5] ); | ||
expect( a ).not.to.equal( [1, 2, 3, 4, 5] ); | ||
expect( a ).to.deep.equal( [1, 2, 3, 4, 5] ); | ||
@@ -46,4 +48,4 @@ done(); | ||
test( 'compact', function( done ) { | ||
expect( [0, 1, undefined, 2, null, 3, NaN, 4, false, 5].compact() ).to.eql( [0, 1, 2, 3, 4, false, 5] ); | ||
expect( [0, 1, undefined, 2, null, 3, NaN, 4, false, 5].compact( true ) ).to.eql( [1, 2, 3, 4, 5] ); | ||
expect( [0, 1, undefined, 2, null, 3, NaN, 4, false, 5].compact() ).to.deep.equal( [0, 1, 2, 3, 4, false, 5] ); | ||
expect( [0, 1, undefined, 2, null, 3, NaN, 4, false, 5].compact( true ) ).to.deep.equal( [1, 2, 3, 4, 5] ); | ||
@@ -56,6 +58,6 @@ done(); | ||
expect( a.contains( 1 ) ).to.be( true ); | ||
expect( a.contains( 2 ) ).to.be( true ); | ||
expect( a.contains( 3 ) ).to.be( true ); | ||
expect( a.contains( 4 ) ).to.be( false ); | ||
expect( a.contains( 1 ) ).to.equal( true ); | ||
expect( a.contains( 2 ) ).to.equal( true ); | ||
expect( a.contains( 3 ) ).to.equal( true ); | ||
expect( a.contains( 4 ) ).to.equal( false ); | ||
@@ -68,6 +70,6 @@ done(); | ||
expect( a.each( function( o, i ) { | ||
expect( o ).to.eql( a[i] ); | ||
expect( this ).to.be( ctx ); | ||
}, ctx ) ).to.eql( a ); | ||
expect( a.each( function( o, i ) { | ||
expect( o ).to.deep.equal( a[i] ); | ||
expect( this ).to.equal( ctx ); | ||
}, ctx ) ).to.deep.equal( a ); | ||
@@ -78,6 +80,5 @@ done(); | ||
test( 'find', function( done ) { | ||
expect( [1, 2, 3, 4, 5].find( function( v ) { return v == 3; } ) ).to.deep.equal( 3 ); | ||
expect( [1, 2, 3, 4, 5].find( function( v ) { return v == 6; } ) ).to.equal( null ); | ||
expect( [1, 2, 3, 4, 5].find( function( v ) { return v == 3; } ) ).to.eql( 3 ); | ||
expect( [1, 2, 3, 4, 5].find( function( v ) { return v == 6; } ) ).to.be( null ); | ||
done(); | ||
@@ -89,5 +90,5 @@ } ); | ||
expect( a.flatten() ).to.eql( [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] ); | ||
expect( a.flatten( 1 ) ).to.eql( [1, 2, 3, 4, 5, 6, [7, 8, 9, [10, 11, 12]]] ); | ||
expect( a.flatten( 2 ) ).to.eql( [1, 2, 3, 4, 5, 6, 7, 8, 9, [10, 11, 12]] ); | ||
expect( a.flatten() ).to.deep.equal( [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] ); | ||
expect( a.flatten( 1 ) ).to.deep.equal( [1, 2, 3, 4, 5, 6, [7, 8, 9, [10, 11, 12]]] ); | ||
expect( a.flatten( 2 ) ).to.deep.equal( [1, 2, 3, 4, 5, 6, 7, 8, 9, [10, 11, 12]] ); | ||
@@ -100,4 +101,4 @@ done(); | ||
expect( a.grep( /a/g, function( o, i ) { return i; } ) ).to.eql( [0, 1, 2] ); | ||
expect( a.grep( /z/g ) ).to.eql( [] ); | ||
expect( a.grep( /a/g, function( o, i ) { return i; } ) ).to.deep.equal( [0, 1, 2] ); | ||
expect( a.grep( /z/g ) ).to.deep.equal( [] ); | ||
@@ -114,5 +115,5 @@ done(); | ||
expect( a.groupBy( 'role' ) ).to.eql( { foo : [o1, o2], bar : [o3, o4] } ); | ||
expect( a.groupBy( function( o ) { return o.cls.contains( 'one' ); } ) ).to.eql( { 0 : [o1, o2, o3], 1 : [o4] } ); | ||
expect( a.pluck( 'cls' ).groupBy( /one/ ) ).to.eql( { 0 : ['one', 'one', 'one two'], 1 : ['two'] } ); | ||
expect( a.groupBy( 'role' ) ).to.deep.equal( { foo : [o1, o2], bar : [o3, o4] } ); | ||
expect( a.groupBy( function( o ) { return o.cls.contains( 'one' ); } ) ).to.deep.equal( { 0 : [o1, o2, o3], 1 : [o4] } ); | ||
expect( a.pluck( 'cls' ).groupBy( /one/ ) ).to.deep.equal( { 0 : ['one', 'one', 'one two'], 1 : ['two'] } ); | ||
@@ -125,5 +126,5 @@ done(); | ||
expect( a.include( 1 ) ).to.be( false ); | ||
expect( a.include( 4 ) ).to.be( true ); | ||
expect( a ).to.eql( [1, 2, 3, 4] ); | ||
expect( a.include( 1 ) ).to.equal( false ); | ||
expect( a.include( 4 ) ).to.equal( true ); | ||
expect( a ).to.deep.equal( [1, 2, 3, 4] ); | ||
@@ -134,3 +135,3 @@ done(); | ||
test( 'invoke', function( done ) { | ||
expect( [1, 2, 3, 4, 5].invoke( 'pad', 3 ) ).to.eql( ['001', '002', '003', '004', '005'] ); | ||
expect( [1, 2, 3, 4, 5].invoke( 'pad', 3 ) ).to.deep.equal( ['001', '002', '003', '004', '005'] ); | ||
@@ -141,10 +142,10 @@ done(); | ||
test( 'invokec', function( done ) { | ||
expect( [ | ||
{ toString : function() { return null; } }, | ||
{ toString : function() { return 1; } }, | ||
{ toString : function() { return undefined; } }, | ||
{ toString : function() { return 2; } }, | ||
{ toString : function() { return NaN; } }, | ||
{ toString : function() { return 3; } } | ||
].invokec( 'toString' ) ).to.eql( [1, 2, 3] ); | ||
expect( [ | ||
{ toString : function() { return null; } }, | ||
{ toString : function() { return 1; } }, | ||
{ toString : function() { return undefined; } }, | ||
{ toString : function() { return 2; } }, | ||
{ toString : function() { return NaN; } }, | ||
{ toString : function() { return 3; } } | ||
].invokec( 'toString' ) ).to.deep.equal( [1, 2, 3] ); | ||
@@ -155,6 +156,6 @@ done(); | ||
test( 'item', function( done ) { | ||
expect( [1, 2, 3, 4, 5].item( 0 ) ).to.eql( 1 ); | ||
expect( [1, 2, 3, 4, 5].item( -1 ) ).to.eql( 5 ); | ||
expect( [1, 2, 3, 4, 5].item( -3 ) ).to.eql( 3 ); | ||
expect( [1, 2, 3, 4, 5].item( 2 ) ).to.eql( 3 ); | ||
expect( [1, 2, 3, 4, 5].item( 0 ) ).to.deep.equal( 1 ); | ||
expect( [1, 2, 3, 4, 5].item( -1 ) ).to.deep.equal( 5 ); | ||
expect( [1, 2, 3, 4, 5].item( -3 ) ).to.deep.equal( 3 ); | ||
expect( [1, 2, 3, 4, 5].item( 2 ) ).to.deep.equal( 3 ); | ||
@@ -165,3 +166,3 @@ done(); | ||
test( 'last', function( done ) { | ||
expect( [1, 2, 3, 4, 5].last() ).to.eql( 5 ); | ||
expect( [1, 2, 3, 4, 5].last() ).to.deep.equal( 5 ); | ||
@@ -172,3 +173,3 @@ done(); | ||
test( 'mapc', function( done ) { | ||
expect( [1, undefined, 2, null, 3, NaN].mapc( m8 ) ).to.eql( [1,2,3] ); | ||
expect( [1, undefined, 2, null, 3, NaN].mapc( m8 ) ).to.deep.equal( [1,2,3] ); | ||
@@ -179,20 +180,20 @@ done(); | ||
test( 'pluck', function( done ) { | ||
expect( [ | ||
{ 'one' : 1, 'two' : 2, 'three' : 3 }, | ||
{ 'one' : 1, 'two' : 2, 'three' : 3 }, | ||
{ 'one' : 1, 'two' : 2, 'three' : 3 } | ||
].pluck( 'one' ) ).to.eql( [1, 1, 1] ); | ||
expect( [ | ||
{ 'one' : 1, 'two' : 2, 'three' : 3 }, | ||
{ 'one' : undefined, 'two' : 2, 'three' : 3 }, | ||
{ 'one' : 1, 'two' : 2, 'three' : 3 }, | ||
{ 'one' : null, 'two' : 2, 'three' : 3 }, | ||
{ 'one' : 1, 'two' : 2, 'three' : 3 } | ||
].pluck( 'one', true ) ).to.eql( [1, 1, 1] ); | ||
expect( m8.range( 1, 10 ).map( function( o, i ) { | ||
return { src : { val : i } }; | ||
} ).pluck( 'src.val' ) ).to.eql( m8.range( 0, 9 ) ); | ||
expect( m8.range( 1, 10 ).map( function( o, i ) { | ||
return { src : { val : i % 2 ? i : null } }; | ||
} ).pluck( 'src.val', true ) ).to.eql( [1, 3, 5, 7, 9] ); | ||
expect( [ | ||
{ 'one' : 1, 'two' : 2, 'three' : 3 }, | ||
{ 'one' : 1, 'two' : 2, 'three' : 3 }, | ||
{ 'one' : 1, 'two' : 2, 'three' : 3 } | ||
].pluck( 'one' ) ).to.deep.equal( [1, 1, 1] ); | ||
expect( [ | ||
{ 'one' : 1, 'two' : 2, 'three' : 3 }, | ||
{ 'one' : undefined, 'two' : 2, 'three' : 3 }, | ||
{ 'one' : 1, 'two' : 2, 'three' : 3 }, | ||
{ 'one' : null, 'two' : 2, 'three' : 3 }, | ||
{ 'one' : 1, 'two' : 2, 'three' : 3 } | ||
].pluck( 'one', true ) ).to.deep.equal( [1, 1, 1] ); | ||
expect( m8.range( 1, 10 ).map( function( o, i ) { | ||
return { src : { val : i } }; | ||
} ).pluck( 'src.val' ) ).to.deep.equal( m8.range( 0, 9 ) ); | ||
expect( m8.range( 1, 10 ).map( function( o, i ) { | ||
return { src : { val : i % 2 ? i : null } }; | ||
} ).pluck( 'src.val', true ) ).to.deep.equal( [1, 3, 5, 7, 9] ); | ||
@@ -205,4 +206,4 @@ done(); | ||
expect( a.remove( 7, 8, 9 ) ).to.eql( [7, 8, 9] ); | ||
expect( a ).to.eql( m8.range( 0, 6 ) ); | ||
expect( a.remove( 7, 8, 9 ) ).to.deep.equal( [7, 8, 9] ); | ||
expect( a ).to.deep.equal( m8.range( 0, 6 ) ); | ||
@@ -219,10 +220,10 @@ done(); | ||
expect( a.sortBy( 'id', 'desc' ) ).to.eql( [o4, o3, o2, o1] ); | ||
expect( a.sortBy( 'role', 'asc' ) ).to.eql( [o3, o4, o1, o2] ); | ||
expect( a.sortBy( function( o ) { | ||
return o.cls.replace( /\s/g, '' ); | ||
}, | ||
function( a, b ) { | ||
return a[1] == b[1] ? a[0].value > b[0].value ? 1 : -1 : a[1] > b[1] ? 1 : -1; | ||
} ) ).to.eql( [o1, o2, o3, o4] ); | ||
expect( a.sortBy( 'id', 'desc' ) ).to.deep.equal( [o4, o3, o2, o1] ); | ||
expect( a.sortBy( 'role', 'asc' ) ).to.deep.equal( [o3, o4, o1, o2] ); | ||
expect( a.sortBy( function( o ) { | ||
return o.cls.replace( /\s/g, '' ); | ||
}, | ||
function( a, b ) { | ||
return a[1] == b[1] ? a[0].value > b[0].value ? 1 : -1 : a[1] > b[1] ? 1 : -1; | ||
} ) ).to.deep.equal( [o1, o2, o3, o4] ); | ||
@@ -233,20 +234,20 @@ done(); | ||
test( 'tuck', function( done ) { | ||
expect( [ | ||
{ 'one' : 1, 'two' : 2, 'three' : 3 }, | ||
{ 'one' : 1, 'two' : 2, 'three' : 3 }, | ||
{ 'one' : 1, 'two' : 2, 'three' : 3 } | ||
].tuck( 'four', 4 ) ).to.eql( [ | ||
{ 'one' : 1, 'two' : 2, 'three' : 3, 'four' : 4 }, | ||
{ 'one' : 1, 'two' : 2, 'three' : 3, 'four' : 4 }, | ||
{ 'one' : 1, 'two' : 2, 'three' : 3, 'four' : 4 } | ||
] ); | ||
expect( [ | ||
{ 'one' : 1, 'two' : 2, 'three' : 3 }, | ||
{ 'one' : 1, 'two' : 2, 'three' : 3 }, | ||
{ 'one' : 1, 'two' : 2, 'three' : 3 } | ||
].tuck( 'four', [4, 5, 6] ) ).to.eql( [ | ||
{ 'one' : 1, 'two' : 2, 'three' : 3, 'four' : 4 }, | ||
{ 'one' : 1, 'two' : 2, 'three' : 3, 'four' : 5 }, | ||
{ 'one' : 1, 'two' : 2, 'three' : 3, 'four' : 6 } | ||
] ); | ||
expect( [ | ||
{ 'one' : 1, 'two' : 2, 'three' : 3 }, | ||
{ 'one' : 1, 'two' : 2, 'three' : 3 }, | ||
{ 'one' : 1, 'two' : 2, 'three' : 3 } | ||
].tuck( 'four', 4 ) ).to.deep.equal( [ | ||
{ 'one' : 1, 'two' : 2, 'three' : 3, 'four' : 4 }, | ||
{ 'one' : 1, 'two' : 2, 'three' : 3, 'four' : 4 }, | ||
{ 'one' : 1, 'two' : 2, 'three' : 3, 'four' : 4 } | ||
] ); | ||
expect( [ | ||
{ 'one' : 1, 'two' : 2, 'three' : 3 }, | ||
{ 'one' : 1, 'two' : 2, 'three' : 3 }, | ||
{ 'one' : 1, 'two' : 2, 'three' : 3 } | ||
].tuck( 'four', [4, 5, 6] ) ).to.deep.equal( [ | ||
{ 'one' : 1, 'two' : 2, 'three' : 3, 'four' : 4 }, | ||
{ 'one' : 1, 'two' : 2, 'three' : 3, 'four' : 5 }, | ||
{ 'one' : 1, 'two' : 2, 'three' : 3, 'four' : 6 } | ||
] ); | ||
@@ -261,5 +262,5 @@ done(); | ||
expect( r ).not.to.be( a ); | ||
expect( r ).to.eql( e ); | ||
expect( r ).to.eql( e ); | ||
expect( r ).not.to.equal( a ); | ||
expect( r ).to.deep.equal( e ); | ||
expect( r ).to.deep.equal( e ); | ||
@@ -272,4 +273,4 @@ done(); | ||
expect( a.without( 7, 8, 9 ) ).to.eql( m8.range( 0, 6 ) ); | ||
expect( a ).to.eql( m8.range( 0, 9 ) ); | ||
expect( a.without( 7, 8, 9 ) ).to.deep.equal( m8.range( 0, 6 ) ); | ||
expect( a ).to.deep.equal( m8.range( 0, 9 ) ); | ||
@@ -282,3 +283,3 @@ done(); | ||
expect( a2.zip( a1, a3 ) ).to.eql( [[1, 'one', 'a'], [2, 'two', 'b'], [3, 'three', 'c']] ); | ||
expect( a2.zip( a1, a3 ) ).to.deep.equal( [[1, 'one', 'a'], [2, 'two', 'b'], [3, 'three', 'c']] ); | ||
@@ -285,0 +286,0 @@ done(); |
@@ -1,5 +0,7 @@ | ||
typeof m8 !== 'undefined' || ( m8 = require( 'm8' ) ); | ||
typeof n8iv !== 'undefined' || ( n8iv = require( 'n8iv' ) ); | ||
typeof expect !== 'undefined' || ( expect = require( 'expect.js' ) ); | ||
typeof m8 !== 'undefined' || ( m8 = require( 'm8' ) ); | ||
typeof n8iv !== 'undefined' || ( n8iv = require( 'n8iv' ) ); | ||
typeof chai !== 'undefined' || ( chai = require( 'chai' ) ); | ||
expect = chai.expect; | ||
suite( 'Function', function() { | ||
@@ -9,5 +11,5 @@ test( '<static> coerce', function( done ) { | ||
expect( Function.coerce( 'foo' )( 1, 2, 3) ).to.be( 'foo' ); | ||
expect( Function.coerce( a )( 4, 5, 6 ) ).to.be( a ); | ||
expect( Function.coerce( function( a, b, c ) { return [a, b, c]; } )( 7, 8, 9 ) ).to.eql( [7, 8, 9] ); | ||
expect( Function.coerce( 'foo' )( 1, 2, 3) ).to.equal( 'foo' ); | ||
expect( Function.coerce( a )( 4, 5, 6 ) ).to.equal( a ); | ||
expect( Function.coerce( function( a, b, c ) { return [a, b, c]; } )( 7, 8, 9 ) ).to.deep.equal( [7, 8, 9] ); | ||
@@ -18,5 +20,5 @@ done(); | ||
test( 'params', function( done ) { | ||
expect( function( one ){}.params ).to.eql( ['one'] ); | ||
expect( function( one, two, three ){}.params ).to.eql( ['one', 'two', 'three'] ); | ||
expect( function(){}.params ).to.eql( [] ); | ||
expect( function( one ){}.params ).to.deep.equal( ['one'] ); | ||
expect( function( one, two, three ){}.params ).to.deep.equal( ['one', 'two', 'three'] ); | ||
expect( function(){}.params ).to.deep.equal( [] ); | ||
@@ -29,10 +31,10 @@ done(); | ||
expect( ( function() { | ||
expect( this ).to.be( ctx ); | ||
expect( arguments ).to.eql( [1, 2, 3] ); | ||
return true; | ||
} ).attempt( ctx, 1, 2, 3 ) ).to.be( true ); | ||
expect( function() { | ||
throw new TypeError( 'TestError' ); | ||
}.attempt() ).to.be.a( TypeError ); | ||
expect( ( function() { | ||
expect( this ).to.equal( ctx ); | ||
expect( arguments ).to.deep.equal( [1, 2, 3] ); | ||
return true; | ||
} ).attempt( ctx, 1, 2, 3 ) ).to.equal( true ); | ||
expect( function() { | ||
throw new TypeError( 'TestError' ); | ||
}.attempt() ).to.be.an.instanceof( TypeError ); | ||
@@ -43,14 +45,14 @@ done(); | ||
test( 'bake', function( done ) { | ||
function testBake( o, a, b, c ) { | ||
expect( o ).to.be( test ); | ||
expect( a ).to.eql( 1 ); | ||
expect( b ).to.eql( 2 ); | ||
expect( c ).to.eql( 3 ); | ||
} | ||
function testBake( o, a, b, c ) { | ||
expect( o ).to.equal( test ); | ||
expect( a ).to.deep.equal( 1 ); | ||
expect( b ).to.deep.equal( 2 ); | ||
expect( c ).to.deep.equal( 3 ); | ||
} | ||
function Test() {} | ||
Test.prototype.baked = testBake.bake(); | ||
function Test() {} | ||
Test.prototype.baked = testBake.bake(); | ||
var test = new Test(); | ||
test.baked( 1, 2, 3 ); | ||
var test = new Test(); | ||
test.baked( 1, 2, 3 ); | ||
@@ -65,9 +67,10 @@ done(); | ||
expect( Date.now() - n ).to.be.within( 0, 50 ); | ||
expect( r ).to.be( ctx ); | ||
expect( a ).to.eql( [1, 2, 3] ); | ||
// the reason the range is so high is because MSIE 10 f**ks out, MSIE9 and every other browser are fine | ||
// must be one of them improved MSIE10 features, improved f**king out | ||
expect( Date.now() - n ).to.be.within( 0, 250 ); | ||
expect( r ).to.equal( ctx ); | ||
expect( a ).to.deep.equal( [1, 2, 3] ); | ||
done(); | ||
} ).defer( ctx, 1, 2, 3 ); | ||
} ); | ||
@@ -79,9 +82,9 @@ | ||
var a = arguments, r = this; | ||
expect( Date.now() - n ).to.be.within( 110, 175 ); | ||
expect( r ).to.be( ctx ); | ||
expect( a ).to.eql( [1, 2, 3] ); | ||
expect( Date.now() - n ).to.be.within( 110, 175 ); | ||
expect( r ).to.equal( ctx ); | ||
expect( a ).to.deep.equal( [1, 2, 3] ); | ||
done(); | ||
} ).delay( 125, ctx, 1, 2, 3 ); | ||
} ); | ||
@@ -99,8 +102,8 @@ | ||
expect( test_memoized ).not.to.be( tm_original ); | ||
expect( test_memoized( 'testing' ) ).to.eql( 'testing' ); | ||
expect( test_memoized( 'testing', 'memoization' ) ).to.eql( 'testing memoization' ); | ||
expect( test_memoized( 'testing', 'memoization', 'but' ) ).to.eql( 'testing memoization but' ); | ||
expect( test_memoized( 'testing', 'memoization', 'but', 'not' ) ).to.eql( 'testing memoization but not' ); | ||
expect( test_memoized( 'testing', 'memoization', 'but', 'not', 'optimisation' ) ).to.eql( 'testing memoization but not optimisation' ); | ||
expect( test_memoized ).not.to.equal( tm_original ); | ||
expect( test_memoized( 'testing' ) ).to.deep.equal( 'testing' ); | ||
expect( test_memoized( 'testing', 'memoization' ) ).to.deep.equal( 'testing memoization' ); | ||
expect( test_memoized( 'testing', 'memoization', 'but' ) ).to.deep.equal( 'testing memoization but' ); | ||
expect( test_memoized( 'testing', 'memoization', 'but', 'not' ) ).to.deep.equal( 'testing memoization but not' ); | ||
expect( test_memoized( 'testing', 'memoization', 'but', 'not', 'optimisation' ) ).to.deep.equal( 'testing memoization but not optimisation' ); | ||
@@ -115,6 +118,6 @@ done(); | ||
expect( one ).not.to.be( two ); | ||
expect( one ).not.to.eql( two ); | ||
expect( one.valueOf() ).to.eql( two.valueOf() ); | ||
expect( one.toString() ).to.eql( two.toString() ); | ||
expect( one ).not.to.equal( two ); | ||
expect( one ).not.to.deep.equal( two ); | ||
expect( one.valueOf() ).to.deep.equal( two.valueOf() ); | ||
expect( one.toString() ).to.deep.equal( two.toString() ); | ||
@@ -129,4 +132,3 @@ done(); | ||
} )(); | ||
} ); | ||
} ); |
@@ -1,15 +0,17 @@ | ||
typeof m8 !== 'undefined' || ( m8 = require( 'm8' ) ); | ||
typeof n8iv !== 'undefined' || ( n8iv = require( 'n8iv' ) ); | ||
typeof expect !== 'undefined' || ( expect = require( 'expect.js' ) ); | ||
typeof m8 !== 'undefined' || ( m8 = require( 'm8' ) ); | ||
typeof n8iv !== 'undefined' || ( n8iv = require( 'n8iv' ) ); | ||
typeof chai !== 'undefined' || ( chai = require( 'chai' ) ); | ||
expect = chai.expect; | ||
suite( 'Number', function() { | ||
test( '<static> isInteger', function( done ) { | ||
expect( Number.isInteger( 1 ) ).to.be( true ); | ||
expect( Number.isInteger( parseInt( '0x1e10' ) ) ).to.be( true ); | ||
expect( Number.isInteger( Number.toInteger( '0x1e10' ) ) ).to.be( true ); | ||
expect( Number.isInteger( Infinity ) ).to.be( false ); | ||
expect( Number.isInteger( -Infinity ) ).to.be( false ); | ||
expect( Number.isInteger( Number.MIN_VALUE ) ).to.be( false ); | ||
expect( Number.isInteger( Number.MAX_VALUE ) ).to.be( false ); | ||
expect( Number.isInteger( '0x1e10' ) ).to.be( false ); | ||
expect( Number.isInteger( 1 ) ).to.equal( true ); | ||
expect( Number.isInteger( parseInt( '0x1e10' ) ) ).to.equal( true ); | ||
expect( Number.isInteger( Number.toInteger( '0x1e10' ) ) ).to.equal( true ); | ||
expect( Number.isInteger( Infinity ) ).to.equal( false ); | ||
expect( Number.isInteger( -Infinity ) ).to.equal( false ); | ||
expect( Number.isInteger( Number.MIN_VALUE ) ).to.equal( false ); | ||
expect( Number.isInteger( Number.MAX_VALUE ) ).to.equal( false ); | ||
expect( Number.isInteger( '0x1e10' ) ).to.equal( false ); | ||
@@ -20,9 +22,9 @@ done(); | ||
test( '<static> toInteger', function( done ) { | ||
expect( Number.toInteger( '1' ) ).to.eql( 1 ); | ||
expect( Number.toInteger( 'Infinity' ) ).to.eql( Number.POSITIVE_INFINITY ); | ||
expect( Number.toInteger( '-Infinity' ) ).to.eql( Number.NEGATIVE_INFINITY ); | ||
// expect( Number.toInteger( String( Number.MIN_VALUE ) ) ).to.eql( 0 ); | ||
expect( Number.toInteger( String( Number.MAX_VALUE ) ) ).to.eql( Number.MAX_VALUE ); | ||
expect( Number.toInteger( 'foo' ) ).to.eql( 0 ); | ||
expect( Number.toInteger( '0x1e10' ) ).to.eql( 7696 ); | ||
expect( Number.toInteger( '1' ) ).to.deep.equal( 1 ); | ||
expect( Number.toInteger( 'Infinity' ) ).to.deep.equal( Number.POSITIVE_INFINITY ); | ||
expect( Number.toInteger( '-Infinity' ) ).to.deep.equal( Number.NEGATIVE_INFINITY ); | ||
// expect( Number.toInteger( String( Number.MIN_VALUE ) ) ).to.deep.equal( 0 ); | ||
expect( Number.toInteger( String( Number.MAX_VALUE ) ) ).to.deep.equal( Number.MAX_VALUE ); | ||
expect( Number.toInteger( 'foo' ) ).to.deep.equal( 0 ); | ||
expect( Number.toInteger( '0x1e10' ) ).to.deep.equal( 7696 ); | ||
@@ -33,4 +35,4 @@ done(); | ||
test( 'pad', function( done ) { | ||
expect( ( 1 ).pad( 3 ) ).to.eql( '001' ); | ||
expect( ( 100 ).pad( 3 ) ).to.eql( '100' ); | ||
expect( ( 1 ).pad( 3 ) ).to.deep.equal( '001' ); | ||
expect( ( 100 ).pad( 3 ) ).to.deep.equal( '100' ); | ||
@@ -43,7 +45,7 @@ done(); | ||
( 3 ).times( function( o, i ) { | ||
expect( o ).to.eql( i ); | ||
++count; | ||
} ); | ||
expect( count ).to.eql( 3 ); | ||
( 3 ).times( function( o, i ) { | ||
expect( o ).to.deep.equal( i ); | ||
++count; | ||
} ); | ||
expect( count ).to.deep.equal( 3 ); | ||
@@ -54,5 +56,5 @@ done(); | ||
test( 'toHex', function( done ) { | ||
expect( ( 0 ).toHex() ).to.eql( '00' ); | ||
expect( ( 127 ).toHex() ).to.eql( '7f' ); | ||
expect( ( 255 ).toHex() ).to.eql( 'ff' ); | ||
expect( ( 0 ).toHex() ).to.deep.equal( '00' ); | ||
expect( ( 127 ).toHex() ).to.deep.equal( '7f' ); | ||
expect( ( 255 ).toHex() ).to.deep.equal( 'ff' ); | ||
@@ -59,0 +61,0 @@ done(); |
@@ -1,10 +0,12 @@ | ||
typeof m8 !== 'undefined' || ( m8 = require( 'm8' ) ); | ||
typeof n8iv !== 'undefined' || ( n8iv = require( 'n8iv' ) ); | ||
typeof expect !== 'undefined' || ( expect = require( 'expect.js' ) ); | ||
typeof m8 !== 'undefined' || ( m8 = require( 'm8' ) ); | ||
typeof n8iv !== 'undefined' || ( n8iv = require( 'n8iv' ) ); | ||
typeof chai !== 'undefined' || ( chai = require( 'chai' ) ); | ||
expect = chai.expect; | ||
suite( 'Object', function() { | ||
test( '<static> aggregate', function( done ) { | ||
expect( Object.aggregate( { one : 1, two : 2, three : 3, four : 4, five : 5 }, 0, function( res, v, k, o ) { | ||
return res += v; | ||
} ) ).to.eql( 15 ); | ||
expect( Object.aggregate( { one : 1, two : 2, three : 3, four : 4, five : 5 }, 0, function( res, v, k, o ) { | ||
return res += v; | ||
} ) ).to.deep.equal( 15 ); | ||
@@ -15,3 +17,3 @@ done(); | ||
test( '<static> clear', function( done ) { | ||
expect( m8.empty( Object.clear( { one : 1, two : 2, three : 3, four : 4, five : 5 } ) ) ).to.be( true ); | ||
expect( m8.empty( Object.clear( { one : 1, two : 2, three : 3, four : 4, five : 5 } ) ) ).to.equal( true ); | ||
@@ -22,10 +24,10 @@ done(); | ||
test( '<static> equalTo', function( done ) { | ||
expect( Object.equalTo( { one : 1, two : 2, three : 3 }, { one : 1, two : 2, three : 3 } ) ).to.be( true ); | ||
expect( Object.equalTo( Object.keys( { one : 1, two : 2, three : 3 } ), Object.keys( { one : 1, two : 2, three : 3 } ) ) ).to.be( true ); | ||
expect( Object.equalTo( Object.values( { one : 1, two : 2, three : 3 } ), Object.values( { one : 1, two : 2, three : 3 } ) ) ).to.be( true ); | ||
expect( Object.equalTo( new Date( 2012, 0, 1 ), new Date( 2012, 0, 1 ) ) ).to.be( true ); | ||
expect( Object.equalTo( { one : 1, two : 2, three : 3, four : 4 }, { one : 1, two : 2, three : 3 } ) ).to.be( false ); | ||
expect( Object.equalTo( { one : 1, two : 2, three : 3 }, { one : 1, two : 2, three : 3, four : 4 } ) ).to.be( false ); | ||
expect( Object.equalTo( { one : 1, two : 2, three : 3, four : 4 }, { one : 1, two : 2, three : 3 } ) ).to.be( false ); | ||
expect( Object.equalTo( { one : 1, two : 2, three : 3 }, { one : 1, two : 2, three : 3, four : 4 } ) ).to.be( false ); | ||
expect( Object.equalTo( { one : 1, two : 2, three : 3 }, { one : 1, two : 2, three : 3 } ) ).to.equal( true ); | ||
expect( Object.equalTo( Object.keys( { one : 1, two : 2, three : 3 } ), Object.keys( { one : 1, two : 2, three : 3 } ) ) ).to.equal( true ); | ||
expect( Object.equalTo( Object.values( { one : 1, two : 2, three : 3 } ), Object.values( { one : 1, two : 2, three : 3 } ) ) ).to.equal( true ); | ||
expect( Object.equalTo( new Date( 2012, 0, 1 ), new Date( 2012, 0, 1 ) ) ).to.equal( true ); | ||
expect( Object.equalTo( { one : 1, two : 2, three : 3, four : 4 }, { one : 1, two : 2, three : 3 } ) ).to.equal( false ); | ||
expect( Object.equalTo( { one : 1, two : 2, three : 3 }, { one : 1, two : 2, three : 3, four : 4 } ) ).to.equal( false ); | ||
expect( Object.equalTo( { one : 1, two : 2, three : 3, four : 4 }, { one : 1, two : 2, three : 3 } ) ).to.equal( false ); | ||
expect( Object.equalTo( { one : 1, two : 2, three : 3 }, { one : 1, two : 2, three : 3, four : 4 } ) ).to.equal( false ); | ||
@@ -36,4 +38,4 @@ done(); | ||
test( '<static> ownKeys', function( done ) { | ||
expect( Object.ownKeys( { foo : 'bar' } ) ).to.eql( ['foo'] ); | ||
expect( Object.ownKeys( ['foo', 'bar'] ).sort() ).to.eql( ['0', '1', 'length'] ); | ||
expect( Object.ownKeys( { foo : 'bar' } ) ).to.deep.equal( ['foo'] ); | ||
expect( Object.ownKeys( ['foo', 'bar'] ).sort() ).to.deep.equal( ['0', '1', 'length'] ); | ||
@@ -44,4 +46,4 @@ done(); | ||
test( '<static> ownLen', function( done ) { | ||
expect( Object.ownLen( { foo : 'bar' } ) ).to.eql( 1 ); | ||
expect( Object.ownLen( ['foo', 'bar'] ) ).to.eql( 3 ); | ||
expect( Object.ownLen( { foo : 'bar' } ) ).to.deep.equal( 1 ); | ||
expect( Object.ownLen( ['foo', 'bar'] ) ).to.deep.equal( 3 ); | ||
@@ -52,4 +54,4 @@ done(); | ||
test( '<static> values', function( done ) { | ||
expect( Object.values( { one : 1, two : 2, three : 3, four : 4, five : 5 } ) ).to.eql( [1, 2, 3, 4, 5] ); | ||
expect( Object.values( [1, 2, 3, 4, 5] ) ).to.eql( [1, 2, 3, 4, 5] ); | ||
expect( Object.values( { one : 1, two : 2, three : 3, four : 4, five : 5 } ) ).to.deep.equal( [1, 2, 3, 4, 5] ); | ||
expect( Object.values( [1, 2, 3, 4, 5] ) ).to.deep.equal( [1, 2, 3, 4, 5] ); | ||
@@ -56,0 +58,0 @@ done(); |
@@ -1,11 +0,13 @@ | ||
typeof m8 !== 'undefined' || ( m8 = require( 'm8' ) ); | ||
typeof n8iv !== 'undefined' || ( n8iv = require( 'n8iv' ) ); | ||
typeof expect !== 'undefined' || ( expect = require( 'expect.js' ) ); | ||
typeof m8 !== 'undefined' || ( m8 = require( 'm8' ) ); | ||
typeof n8iv !== 'undefined' || ( n8iv = require( 'n8iv' ) ); | ||
typeof chai !== 'undefined' || ( chai = require( 'chai' ) ); | ||
expect = chai.expect; | ||
suite( 'String', function() { | ||
test( 'blank', function( done ) { | ||
expect( ''.blank() ).to.be( true ); | ||
expect( ' '.blank() ).to.be( true ); | ||
expect( ' \t\n\r'.blank() ).to.be( true ); | ||
expect( ' 0 '.blank() ).to.be( false ); | ||
expect( ''.blank() ).to.equal( true ); | ||
expect( ' '.blank() ).to.equal( true ); | ||
expect( ' \t\n\r'.blank() ).to.equal( true ); | ||
expect( ' 0 '.blank() ).to.equal( false ); | ||
@@ -16,6 +18,6 @@ done(); | ||
test( 'capitalize', function( done ) { | ||
expect( 'the quick brown fox jumps over the lazy dog.'.capitalize() ).to.eql( 'The quick brown fox jumps over the lazy dog.' ); | ||
expect( 'The quick brown fox jumps over the lazy dog.'.capitalize() ).to.eql( 'The quick brown fox jumps over the lazy dog.' ); | ||
expect( 'the Quick Brown Fox Jumps Over The Lazy Dog.'.capitalize() ).to.eql( 'The quick brown fox jumps over the lazy dog.' ); | ||
expect( 'The Quick Brown Fox Jumps Over The Lazy Dog.'.capitalize() ).to.eql( 'The quick brown fox jumps over the lazy dog.' ); | ||
expect( 'the quick brown fox jumps over the lazy dog.'.capitalize() ).to.deep.equal( 'The quick brown fox jumps over the lazy dog.' ); | ||
expect( 'The quick brown fox jumps over the lazy dog.'.capitalize() ).to.deep.equal( 'The quick brown fox jumps over the lazy dog.' ); | ||
expect( 'the Quick Brown Fox Jumps Over The Lazy Dog.'.capitalize() ).to.deep.equal( 'The quick brown fox jumps over the lazy dog.' ); | ||
expect( 'The Quick Brown Fox Jumps Over The Lazy Dog.'.capitalize() ).to.deep.equal( 'The quick brown fox jumps over the lazy dog.' ); | ||
@@ -26,4 +28,4 @@ done(); | ||
test( 'clean', function( done ) { | ||
expect( ' the quick brown fox jumps over the lazy dog. '.clean() ).to.eql( 'the quick brown fox jumps over the lazy dog.' ); | ||
expect( ' the quick brown fox jumps over the lazy dog. '.clean( ' ' ) ).to.eql( 'the quick brown fox jumps over the lazy dog.' ); | ||
expect( ' the quick brown fox jumps over the lazy dog. '.clean() ).to.deep.equal( 'the quick brown fox jumps over the lazy dog.' ); | ||
expect( ' the quick brown fox jumps over the lazy dog. '.clean( ' ' ) ).to.deep.equal( 'the quick brown fox jumps over the lazy dog.' ); | ||
@@ -34,7 +36,7 @@ done(); | ||
test( 'contains', function( done ) { | ||
expect( 'the quick brown fox jumps over the lazy dog.'.contains( 'the' ) ).to.be( true ); | ||
expect( 'the quick brown fox jumps over the lazy dog.'.contains( 'quick' ) ).to.be( true ); | ||
expect( 'the quick brown fox jumps over the lazy dog.'.contains( 'lazy' ) ).to.be( true ); | ||
expect( 'the quick brown fox jumps over the lazy dog.'.contains( 'dog' ) ).to.be( true ); | ||
expect( 'the quick brown fox jumps over the lazy dog.'.contains( 'n8iv' ) ).to.be( false ); | ||
expect( 'the quick brown fox jumps over the lazy dog.'.contains( 'the' ) ).to.equal( true ); | ||
expect( 'the quick brown fox jumps over the lazy dog.'.contains( 'quick' ) ).to.equal( true ); | ||
expect( 'the quick brown fox jumps over the lazy dog.'.contains( 'lazy' ) ).to.equal( true ); | ||
expect( 'the quick brown fox jumps over the lazy dog.'.contains( 'dog' ) ).to.equal( true ); | ||
expect( 'the quick brown fox jumps over the lazy dog.'.contains( 'n8iv' ) ).to.equal( false ); | ||
@@ -45,5 +47,5 @@ done(); | ||
test( 'empty', function( done ) { | ||
expect( ''.empty() ).to.be( true ); | ||
expect( ' '.empty() ).to.be( false ); | ||
expect( '0'.empty() ).to.be( false ); | ||
expect( ''.empty() ).to.equal( true ); | ||
expect( ' '.empty() ).to.equal( false ); | ||
expect( '0'.empty() ).to.equal( false ); | ||
@@ -54,5 +56,5 @@ done(); | ||
test( 'endsWith', function( done ) { | ||
expect( 'the quick brown fox jumps over the lazy dog.'.endsWith( 'dog.' ) ).to.be( true ); | ||
expect( 'the quick brown fox jumps over the lazy dog.'.endsWith( 'the' ) ).to.be( false ); | ||
expect( 'the quick brown fox jumps over the lazy dog.'.endsWith( 'n8iv' ) ).to.be( false ); | ||
expect( 'the quick brown fox jumps over the lazy dog.'.endsWith( 'dog.' ) ).to.equal( true ); | ||
expect( 'the quick brown fox jumps over the lazy dog.'.endsWith( 'the' ) ).to.equal( false ); | ||
expect( 'the quick brown fox jumps over the lazy dog.'.endsWith( 'n8iv' ) ).to.equal( false ); | ||
@@ -63,3 +65,3 @@ done(); | ||
test( 'format', function( done ) { | ||
expect( '{0}, {1}, {2}, {3}, {4}, {5}, {6}, ${7}, ${8}, ${9}'.format( 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine' ) ).to.eql( 'zero, one, two, three, four, five, six, seven, eight, nine' ); | ||
expect( '{0}, {1}, {2}, {3}, {4}, {5}, {6}, ${7}, ${8}, ${9}'.format( 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine' ) ).to.deep.equal( 'zero, one, two, three, four, five, six, seven, eight, nine' ); | ||
@@ -70,12 +72,12 @@ done(); | ||
test( 'gsub', function( done ) { | ||
expect( 'The {one} {two} {three} jumps over the ${four} ${five}.'.gsub( { | ||
one : 'quick', two : 'brown', | ||
three : 'fox', four : 'lazy', | ||
five : 'dog' | ||
} ) ).to.eql( 'The quick brown fox jumps over the lazy dog.' ); | ||
expect( 'The ===one=== ===two=== ===three=== jumps over the ===four=== ===five===.'.gsub( { | ||
one : 'quick', two : 'brown', | ||
three : 'fox', four : 'lazy', | ||
five : 'dog' | ||
}, /={3}([^=]+)={3}/g ) ).to.eql( 'The quick brown fox jumps over the lazy dog.' ); | ||
expect( 'The {one} {two} {three} jumps over the ${four} ${five}.'.gsub( { | ||
one : 'quick', two : 'brown', | ||
three : 'fox', four : 'lazy', | ||
five : 'dog' | ||
} ) ).to.deep.equal( 'The quick brown fox jumps over the lazy dog.' ); | ||
expect( 'The ===one=== ===two=== ===three=== jumps over the ===four=== ===five===.'.gsub( { | ||
one : 'quick', two : 'brown', | ||
three : 'fox', four : 'lazy', | ||
five : 'dog' | ||
}, /={3}([^=]+)={3}/g ) ).to.deep.equal( 'The quick brown fox jumps over the lazy dog.' ); | ||
@@ -86,7 +88,7 @@ done(); | ||
test( 'hyphenate', function( done ) { | ||
expect( 'test_string_to_hyphenate'.hyphenate() ).to.eql( 'test-string-to-hyphenate' ); | ||
expect( 'testStringToHyphenate'.hyphenate() ).to.eql( 'test-string-to-hyphenate' ); | ||
expect( 'TestStringToHyphenate'.hyphenate() ).to.eql( 'test-string-to-hyphenate' ); | ||
expect( 'test-string-to-hyphenate'.hyphenate() ).to.eql( 'test-string-to-hyphenate' ); | ||
expect( '1 test string 2 hyphenate'.hyphenate() ).to.eql( '1-test-string-2-hyphenate' ); | ||
expect( 'test_string_to_hyphenate'.hyphenate() ).to.deep.equal( 'test-string-to-hyphenate' ); | ||
expect( 'testStringToHyphenate'.hyphenate() ).to.deep.equal( 'test-string-to-hyphenate' ); | ||
expect( 'TestStringToHyphenate'.hyphenate() ).to.deep.equal( 'test-string-to-hyphenate' ); | ||
expect( 'test-string-to-hyphenate'.hyphenate() ).to.deep.equal( 'test-string-to-hyphenate' ); | ||
expect( '1 test string 2 hyphenate'.hyphenate() ).to.deep.equal( '1-test-string-2-hyphenate' ); | ||
@@ -97,7 +99,7 @@ done(); | ||
test( 'includes', function( done ) { | ||
expect( 'the quick brown fox jumps over the lazy dog.'.includes( 'THE' ) ).to.be( true ); | ||
expect( 'the quick brown fox jumps over the lazy dog.'.includes( 'QUICK' ) ).to.be( true ); | ||
expect( 'the quick brown fox jumps over the lazy dog.'.includes( 'LAZY' ) ).to.be( true ); | ||
expect( 'the quick brown fox jumps over the lazy dog.'.includes( 'DOG' ) ).to.be( true ); | ||
expect( 'the quick brown fox jumps over the lazy dog.'.includes( 'THUD' ) ).to.be( false ); | ||
expect( 'the quick brown fox jumps over the lazy dog.'.includes( 'THE' ) ).to.equal( true ); | ||
expect( 'the quick brown fox jumps over the lazy dog.'.includes( 'QUICK' ) ).to.equal( true ); | ||
expect( 'the quick brown fox jumps over the lazy dog.'.includes( 'LAZY' ) ).to.equal( true ); | ||
expect( 'the quick brown fox jumps over the lazy dog.'.includes( 'DOG' ) ).to.equal( true ); | ||
expect( 'the quick brown fox jumps over the lazy dog.'.includes( 'THUD' ) ).to.equal( false ); | ||
@@ -108,6 +110,6 @@ done(); | ||
test( 'parts', function( done ) { | ||
expect( '{0}{1}{2}'.parts( /\{\d\}/g ) ).to.eql( ['{0}', '{1}', '{2}'] ); | ||
expect( '{0}{1}{2}'.parts( /\d/g ) ).to.eql( ['0', '1', '2'] ); | ||
expect( '{0}4{1}5{2}6'.parts( /\{\d\}/g ) ).to.eql( ['{0}', '{1}', '{2}'] ); | ||
expect( '{0}4{1}5{2}6'.parts( /\d/g ) ).to.eql( ['0', '4', '1', '5', '2', '6'] ); | ||
expect( '{0}{1}{2}'.parts( /\{\d\}/g ) ).to.deep.equal( ['{0}', '{1}', '{2}'] ); | ||
expect( '{0}{1}{2}'.parts( /\d/g ) ).to.deep.equal( ['0', '1', '2'] ); | ||
expect( '{0}4{1}5{2}6'.parts( /\{\d\}/g ) ).to.deep.equal( ['{0}', '{1}', '{2}'] ); | ||
expect( '{0}4{1}5{2}6'.parts( /\d/g ) ).to.deep.equal( ['0', '4', '1', '5', '2', '6'] ); | ||
@@ -118,6 +120,6 @@ done(); | ||
test( 'regexpEsc', function( done ) { | ||
var expected = '!\\(\\)\\*\\+\\.:=\\?\\[\\]\\^\\{\\|\\}\\\\', | ||
returned = '!()*+.:=?[]^{|}\\'.regexpEsc(); | ||
var expected = '!\\(\\)\\*\\+\\.:=\\?\\[\\]\\^\\{\\|\\}\\\\', | ||
returned = '!()*+.:=?[]^{|}\\'.regexpEsc(); | ||
expect( returned ).to.eql( expected ); | ||
expect( returned ).to.deep.equal( expected ); | ||
@@ -128,5 +130,5 @@ done(); | ||
test( 'sliceEvery', function( done ) { | ||
expect( 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789'.sliceEvery( 16 ) ).to.eql( ['AaBbCcDdEeFfGgHh', 'IiJjKkLlMmNnOoPp', 'QqRrSsTtUuVvWwXx', 'YyZz0123456789'] ); | ||
expect( 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789'.sliceEvery( 8 ) ).to.eql( ['AaBbCcDd', 'EeFfGgHh', 'IiJjKkLl', 'MmNnOoPp', 'QqRrSsTt', 'UuVvWwXx', 'YyZz0123', '456789'] ); | ||
expect( 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789'.sliceEvery( 4 ) ).to.eql( ['AaBb', 'CcDd', 'EeFf', 'GgHh', 'IiJj', 'KkLl', 'MmNn', 'OoPp', 'QqRr', 'SsTt', 'UuVv', 'WwXx', 'YyZz', '0123', '4567', '89'] ); | ||
expect( 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789'.sliceEvery( 16 ) ).to.deep.equal( ['AaBbCcDdEeFfGgHh', 'IiJjKkLlMmNnOoPp', 'QqRrSsTtUuVvWwXx', 'YyZz0123456789'] ); | ||
expect( 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789'.sliceEvery( 8 ) ).to.deep.equal( ['AaBbCcDd', 'EeFfGgHh', 'IiJjKkLl', 'MmNnOoPp', 'QqRrSsTt', 'UuVvWwXx', 'YyZz0123', '456789'] ); | ||
expect( 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789'.sliceEvery( 4 ) ).to.deep.equal( ['AaBb', 'CcDd', 'EeFf', 'GgHh', 'IiJj', 'KkLl', 'MmNn', 'OoPp', 'QqRr', 'SsTt', 'UuVv', 'WwXx', 'YyZz', '0123', '4567', '89'] ); | ||
@@ -137,5 +139,5 @@ done(); | ||
test( 'startsWith', function( done ) { | ||
expect( 'the quick brown fox jumps over the lazy dog.'.startsWith( 'the' ) ).to.be( true ); | ||
expect( 'the quick brown fox jumps over the lazy dog.'.startsWith( 'dog.' ) ).to.be( false ); | ||
expect( 'the quick brown fox jumps over the lazy dog.'.startsWith( 'n8iv' ) ).to.be( false ); | ||
expect( 'the quick brown fox jumps over the lazy dog.'.startsWith( 'the' ) ).to.equal( true ); | ||
expect( 'the quick brown fox jumps over the lazy dog.'.startsWith( 'dog.' ) ).to.equal( false ); | ||
expect( 'the quick brown fox jumps over the lazy dog.'.startsWith( 'n8iv' ) ).to.equal( false ); | ||
@@ -146,3 +148,3 @@ done(); | ||
test( 'times', function( done ) { | ||
expect( 'na'.times( 8 ) + ' batman!' ).to.eql( 'nananananananana batman!' ); | ||
expect( 'na'.times( 8 ) + ' batman!' ).to.deep.equal( 'nananananananana batman!' ); | ||
@@ -153,7 +155,7 @@ done(); | ||
test( 'toCamelCase', function( done ) { | ||
expect( 'test_string_to_camel_case'.toCamelCase() ).to.eql( 'testStringToCamelCase' ); | ||
expect( 'testStringToCamelCase'.toCamelCase() ).to.eql( 'testStringToCamelCase' ); | ||
expect( 'TestStringToCamelCase'.toCamelCase() ).to.eql( 'TestStringToCamelCase' ); | ||
expect( 'test-string-to-camel-case'.toCamelCase() ).to.eql( 'testStringToCamelCase' ); | ||
expect( '1 test string 2 camel case'.toCamelCase() ).to.eql( '1TestString2CamelCase' ); | ||
expect( 'test_string_to_camel_case'.toCamelCase() ).to.deep.equal( 'testStringToCamelCase' ); | ||
expect( 'testStringToCamelCase'.toCamelCase() ).to.deep.equal( 'testStringToCamelCase' ); | ||
expect( 'TestStringToCamelCase'.toCamelCase() ).to.deep.equal( 'TestStringToCamelCase' ); | ||
expect( 'test-string-to-camel-case'.toCamelCase() ).to.deep.equal( 'testStringToCamelCase' ); | ||
expect( '1 test string 2 camel case'.toCamelCase() ).to.deep.equal( '1TestString2CamelCase' ); | ||
@@ -164,6 +166,6 @@ done(); | ||
test( 'toHex', function( done ) { | ||
expect( '255'.toHex() ).to.eql( '#ffffff' ); | ||
expect( '255255255'.toHex() ).to.eql( '#ffffff' ); | ||
expect( '255,255,255'.toHex() ).to.eql( '#ffffff' ); | ||
expect( 'rgb(255, 255, 255)'.toHex() ).to.eql( '#ffffff' ); | ||
expect( '255'.toHex() ).to.deep.equal( '#ffffff' ); | ||
expect( '255255255'.toHex() ).to.deep.equal( '#ffffff' ); | ||
expect( '255,255,255'.toHex() ).to.deep.equal( '#ffffff' ); | ||
expect( 'rgb(255, 255, 255)'.toHex() ).to.deep.equal( '#ffffff' ); | ||
@@ -174,3 +176,3 @@ done(); | ||
test( 'toJSON', function( done ) { | ||
expect( '{ "foo" : "bar", "items" : [1, 2, 3] }'.toJSON() ).to.eql( { foo : 'bar', items : [1, 2, 3] } ); | ||
expect( '{ "foo" : "bar", "items" : [1, 2, 3] }'.toJSON() ).to.deep.equal( { foo : 'bar', items : [1, 2, 3] } ); | ||
@@ -181,7 +183,7 @@ done(); | ||
test( 'toRGB', function( done ) { | ||
expect( 'ff'.toRGB() ).to.eql( 'rgb(255, 255, 255)' ); | ||
expect( 'fff'.toRGB() ).to.eql( 'rgb(255, 255, 255)' ); | ||
expect( 'ffffff'.toRGB() ).to.eql( 'rgb(255, 255, 255)' ); | ||
expect( '#ffffff'.toRGB() ).to.eql( 'rgb(255, 255, 255)' ); | ||
expect( '#ffffff'.toRGB( true ) ).to.eql( ['255', '255', '255'] ); | ||
expect( 'ff'.toRGB() ).to.deep.equal( 'rgb(255, 255, 255)' ); | ||
expect( 'fff'.toRGB() ).to.deep.equal( 'rgb(255, 255, 255)' ); | ||
expect( 'ffffff'.toRGB() ).to.deep.equal( 'rgb(255, 255, 255)' ); | ||
expect( '#ffffff'.toRGB() ).to.deep.equal( 'rgb(255, 255, 255)' ); | ||
expect( '#ffffff'.toRGB( true ) ).to.deep.equal( [255, 255, 255] ); | ||
@@ -192,3 +194,3 @@ done(); | ||
test( 'truncate', function( done ) { | ||
expect( 'The quick brown fox jumps over the lazy dog.'.truncate( 20 ) ).to.eql( 'The quick brown fox...' ); | ||
expect( 'The quick brown fox jumps over the lazy dog.'.truncate( 20 ) ).to.deep.equal( 'The quick brown fox...' ); | ||
@@ -199,7 +201,7 @@ done(); | ||
test( 'underscore', function( done ) { | ||
expect( 'test_string_to_underscore'.underscore() ).to.eql( 'test_string_to_underscore' ); | ||
expect( 'testStringToUnderscore'.underscore() ).to.eql( 'test_string_to_underscore' ); | ||
expect( 'TestStringToUnderscore'.underscore() ).to.eql( 'test_string_to_underscore' ); | ||
expect( 'test-string-to-underscore'.underscore() ).to.eql( 'test_string_to_underscore' ); | ||
expect( '1 test string 2 underscore'.underscore() ).to.eql( '1_test_string_2_underscore' ); | ||
expect( 'test_string_to_underscore'.underscore() ).to.deep.equal( 'test_string_to_underscore' ); | ||
expect( 'testStringToUnderscore'.underscore() ).to.deep.equal( 'test_string_to_underscore' ); | ||
expect( 'TestStringToUnderscore'.underscore() ).to.deep.equal( 'test_string_to_underscore' ); | ||
expect( 'test-string-to-underscore'.underscore() ).to.deep.equal( 'test_string_to_underscore' ); | ||
expect( '1 test string 2 underscore'.underscore() ).to.deep.equal( '1_test_string_2_underscore' ); | ||
@@ -206,0 +208,0 @@ done(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
105106
5
28
1289