@ -1,16 +1,16 @@
/ * *
/ * *
* Created by windy on 2018 / 01 / 24.
* Created by windy on 2018 / 01 / 24.
* /
* /
describe ( "baseFunctionTest" , function ( ) {
describe ( "baseFunctionTest" , ( ) => {
before ( function ( ) {
beforeAll ( ( ) => {
} ) ;
} ) ;
/ * *
/ * *
* test _author _windy
* test _author _windy
* /
* /
it ( "formatEl和stripEL" , function ( ) {
it ( "formatEl和stripEL" , ( ) => {
var obj1 = {
var obj1 = {
type : "a" ,
type : "a" ,
pro : { } ,
pro : { } ,
@ -24,53 +24,53 @@ describe("baseFunctionTest", function () {
items : [ ]
items : [ ]
}
}
} ;
} ;
expect ( BI . formatEL ( obj1 ) ) . to . deep . e qual( obj2 ) ;
expect ( BI . formatEL ( obj1 ) ) . toE qual ( obj2 ) ;
expect ( BI . formatEL ( obj2 ) ) . to . deep . e qual( obj2 ) ;
expect ( BI . formatEL ( obj2 ) ) . toE qual ( obj2 ) ;
expect ( BI . stripEL ( obj1 ) ) . to . deep . e qual( obj1 ) ;
expect ( BI . stripEL ( obj1 ) ) . toE qual ( obj1 ) ;
expect ( BI . stripEL ( obj2 ) ) . to . deep . e qual( obj1 ) ;
expect ( BI . stripEL ( obj2 ) ) . toE qual ( obj1 ) ;
} ) ;
} ) ;
/ * *
/ * *
* test _author _windy
* test _author _windy
* /
* /
it ( "encodeURIComponent和decodeURIComponent" , function ( ) {
it ( "encodeURIComponent和decodeURIComponent" , ( ) => {
var targetString = "tableName./\\" ;
var targetString = "tableName./\\" ;
var encodeString = BI . encodeURIComponent ( targetString ) ;
var encodeString = BI . encodeURIComponent ( targetString ) ;
expect ( encodeString ) . to . equal ( "tableName120" ) ;
expect ( encodeString ) . toBe ( "tableName120" ) ;
expect ( BI . decodeURIComponent ( encodeString ) ) . to . equal ( targetString ) ;
expect ( BI . decodeURIComponent ( encodeString ) ) . toBe ( targetString ) ;
} ) ;
} ) ;
/ * *
/ * *
* test _author _windy
* test _author _windy
* /
* /
it ( "count" , function ( ) {
it ( "count" , ( ) => {
var a = [ ] ;
var a = [ ] ;
expect ( BI . count ( 1 , 100 ) ) . to . equal ( 99 ) ;
expect ( BI . count ( 1 , 100 ) ) . toBe ( 99 ) ;
BI . count ( 0 , 100 , function ( v ) {
BI . count ( 0 , 100 , function ( v ) {
a [ v ] = 0 ;
a [ v ] = 0 ;
} ) ;
} ) ;
expect ( a . length ) . to . equal ( 100 ) ;
expect ( a . length ) . toBe ( 100 ) ;
} ) ;
} ) ;
/ * *
/ * *
* test _author _windy
* test _author _windy
* /
* /
it ( "concat" , function ( ) {
it ( "concat" , ( ) => {
expect ( BI . concat ( [ 1 ] , [ 2 ] ) ) . to . deep . e qual( [ 1 , 2 ] ) ;
expect ( BI . concat ( [ 1 ] , [ 2 ] ) ) . toE qual ( [ 1 , 2 ] ) ;
expect ( BI . concat ( 1 , 2 ) ) . to . equal ( "12" ) ;
expect ( BI . concat ( 1 , 2 ) ) . toBe ( "12" ) ;
expect ( BI . concat ( "1" , "2" ) ) . to . equal ( "12" ) ;
expect ( BI . concat ( "1" , "2" ) ) . toBe ( "12" ) ;
expect ( BI . concat ( { a : 1 } , { b : 1 } ) ) . to . deep . e qual( { a : 1 , b : 1 } ) ;
expect ( BI . concat ( { a : 1 } , { b : 1 } ) ) . toE qual ( { a : 1 , b : 1 } ) ;
} ) ;
} ) ;
/ * *
/ * *
* test _author _windy
* test _author _windy
* /
* /
it ( "remove" , function ( ) {
it ( "remove" , ( ) => {
var a = [ 1 , 2 , 3 , 4 , 5 , 6 ] ;
var a = [ 1 , 2 , 3 , 4 , 5 , 6 ] ;
BI . remove ( a , function ( i , v ) {
BI . remove ( a , function ( i , v ) {
return v === 4 ;
return v === 4 ;
} ) ;
} ) ;
expect ( a ) . to . deep . e qual( [ 1 , 2 , 3 , 5 , 6 ] ) ;
expect ( a ) . toE qual ( [ 1 , 2 , 3 , 5 , 6 ] ) ;
var b = {
var b = {
a : 1 ,
a : 1 ,
b : 2
b : 2
@ -78,7 +78,7 @@ describe("baseFunctionTest", function () {
BI . remove ( b , function ( key ) {
BI . remove ( b , function ( key ) {
return key === "a" ;
return key === "a" ;
} ) ;
} ) ;
expect ( b ) . to . deep . e qual( {
expect ( b ) . toE qual ( {
b : 2
b : 2
} ) ;
} ) ;
} ) ;
} ) ;
@ -86,16 +86,16 @@ describe("baseFunctionTest", function () {
/ * *
/ * *
* test _author _windy
* test _author _windy
* /
* /
it ( "removeAt" , function ( ) {
it ( "removeAt" , ( ) => {
var a = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ] ;
var a = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ] ;
BI . removeAt ( a , 2 ) ;
BI . removeAt ( a , 2 ) ;
expect ( a ) . to . deep . e qual( [ 1 , 2 , 4 , 5 , 6 , 7 , 8 , 9 ] ) ;
expect ( a ) . toE qual ( [ 1 , 2 , 4 , 5 , 6 , 7 , 8 , 9 ] ) ;
var b = {
var b = {
a : 1 ,
a : 1 ,
b : 2
b : 2
} ;
} ;
BI . removeAt ( b , "a" ) ;
BI . removeAt ( b , "a" ) ;
expect ( b ) . to . deep . e qual( {
expect ( b ) . toE qual ( {
b : 2
b : 2
} ) ;
} ) ;
} ) ;
} ) ;
@ -103,27 +103,27 @@ describe("baseFunctionTest", function () {
/ * *
/ * *
* test _author _windy
* test _author _windy
* /
* /
it ( "makeArray" , function ( ) {
it ( "makeArray" , ( ) => {
var a = BI . makeArray ( 2 , 1 ) ;
var a = BI . makeArray ( 2 , 1 ) ;
expect ( a ) . to . deep . e qual( [ 1 , 1 ] ) ;
expect ( a ) . toE qual ( [ 1 , 1 ] ) ;
} ) ;
} ) ;
/ * *
/ * *
* test _author _windy
* test _author _windy
* /
* /
it ( "concat-string" , function ( ) {
it ( "concat-string" , ( ) => {
// concat-string
// concat-string
expect ( BI . concat ( "a" , "b" , "c" ) ) . to . equal ( "abc" ) ;
expect ( BI . concat ( "a" , "b" , "c" ) ) . toBe ( "abc" ) ;
// concat-array
// concat-array
expect ( BI . concat ( [ 1 ] , [ 2 ] , [ 3 ] ) ) . to . deep . e qual( [ 1 , 2 , 3 ] ) ;
expect ( BI . concat ( [ 1 ] , [ 2 ] , [ 3 ] ) ) . toE qual ( [ 1 , 2 , 3 ] ) ;
// concat-object-array
// concat-object-array
expect ( BI . concat ( [ { text : 1 , value : 1 } ] , [ { text : 2 , value : 2 } ] , [ { text : 3 , value : 3 } ] ) ) . to . deep . e qual( [ { text : 1 , value : 1 } , { text : 2 , value : 2 } , { text : 3 , value : 3 } ] ) ;
expect ( BI . concat ( [ { text : 1 , value : 1 } ] , [ { text : 2 , value : 2 } ] , [ { text : 3 , value : 3 } ] ) ) . toE qual ( [ { text : 1 , value : 1 } , { text : 2 , value : 2 } , { text : 3 , value : 3 } ] ) ;
// concat-object
// concat-object
expect ( BI . concat ( { a : 1 } , { b : 2 } , { c : 3 } ) ) . to . deep . e qual( {
expect ( BI . concat ( { a : 1 } , { b : 2 } , { c : 3 } ) ) . toE qual ( {
a : 1 ,
a : 1 ,
b : 2 ,
b : 2 ,
c : 3
c : 3
@ -133,11 +133,11 @@ describe("baseFunctionTest", function () {
/ * *
/ * *
* test _author _windy
* test _author _windy
* /
* /
it ( "assert-warning" , function ( ) {
it ( "assert-warning" , ( ) => {
expect ( BI . assert ( "a" , "a" ) ) . to . equal ( true ) ;
expect ( BI . assert ( "a" , "a" ) ) . toBe ( true ) ;
expect ( BI . assert ( "a" , function ( v ) {
expect ( BI . assert ( "a" , function ( v ) {
return v === "a" ;
return v === "a" ;
} ) ) . to . equal ( true ) ;
} ) ) . toBe ( true ) ;
var test = "" ;
var test = "" ;
try {
try {
BI . assert ( "a" , function ( v ) {
BI . assert ( "a" , function ( v ) {
@ -146,13 +146,13 @@ describe("baseFunctionTest", function () {
} catch ( e ) {
} catch ( e ) {
test = true ;
test = true ;
}
}
expect ( test ) . to . equal ( true ) ;
expect ( test ) . toBe ( true ) ;
} ) ;
} ) ;
/ * *
/ * *
* test _author _windy
* test _author _windy
* /
* /
it ( "packageItems" , function ( ) {
it ( "packageItems" , ( ) => {
expect ( BI . packageItems ( [ {
expect ( BI . packageItems ( [ {
type : "a" ,
type : "a" ,
text : "b"
text : "b"
@ -163,7 +163,7 @@ describe("baseFunctionTest", function () {
type : "bi.vertical"
type : "bi.vertical"
} , {
} , {
type : "bi.center_adapt"
type : "bi.center_adapt"
} ] ) ) . to . deep . e qual( [ {
} ] ) ) . toE qual ( [ {
type : "bi.vertical" ,
type : "bi.vertical" ,
items : [ {
items : [ {
el : {
el : {
@ -195,29 +195,29 @@ describe("baseFunctionTest", function () {
/ * *
/ * *
* test _author _windy
* test _author _windy
* /
* /
it ( "inverse" , function ( ) {
it ( "inverse" , ( ) => {
expect ( BI . inverse ( 7 , 1 ) ) . to . equal ( 6 ) ;
expect ( BI . inverse ( 7 , 1 ) ) . toBe ( 6 ) ;
} ) ;
} ) ;
/ * *
/ * *
* test _author _windy
* test _author _windy
* /
* /
it ( "key" , function ( ) {
it ( "key" , ( ) => {
var a = {
var a = {
c : 1 ,
c : 1 ,
d : 2
d : 2
} ;
} ;
expect ( BI . firstKey ( a ) ) . to . equal ( "c" ) ;
expect ( BI . firstKey ( a ) ) . toBe ( "c" ) ;
expect ( BI . lastKey ( a ) ) . to . equal ( "d" ) ;
expect ( BI . lastKey ( a ) ) . toBe ( "d" ) ;
expect ( BI . firstObject ( a ) ) . to . equal ( 1 ) ;
expect ( BI . firstObject ( a ) ) . toBe ( 1 ) ;
expect ( BI . lastObject ( a ) ) . to . equal ( 2 ) ;
expect ( BI . lastObject ( a ) ) . toBe ( 2 ) ;
} ) ;
} ) ;
/ * *
/ * *
* test _author _windy
* test _author _windy
* /
* /
it ( "back" , function ( ) {
it ( "back" , ( ) => {
var a = [ {
var a = [ {
c : 1 ,
c : 1 ,
d : 2
d : 2
@ -232,147 +232,147 @@ describe("baseFunctionTest", function () {
BI . backEach ( a , function ( idx , v ) {
BI . backEach ( a , function ( idx , v ) {
c . push ( v . d ) ;
c . push ( v . d ) ;
} ) ;
} ) ;
expect ( c ) . to . deep . e qual( [ 6 , 4 , 2 ] ) ;
expect ( c ) . toE qual ( [ 6 , 4 , 2 ] ) ;
expect ( BI . backEvery ( a , function ( idx , v ) {
expect ( BI . backEvery ( a , function ( idx , v ) {
return v . c = 1 ;
return v . c = 1 ;
} ) ) . to . equal ( true ) ;
} ) ) . toBe ( true ) ;
expect ( BI . backFindKey ( {
expect ( BI . backFindKey ( {
c : 5 ,
c : 5 ,
d : 6
d : 6
} , function ( value , key ) {
} , function ( value , key ) {
return key === "c" ;
return key === "c" ;
} ) ) . to . equal ( "c" ) ;
} ) ) . toBe ( "c" ) ;
expect ( BI . backFind ( {
expect ( BI . backFind ( {
c : 5 ,
c : 5 ,
d : 6
d : 6
} , function ( v , key ) {
} , function ( v , key ) {
return v === 5 ;
return v === 5 ;
} ) ) . to . deep . e qual( 5 ) ;
} ) ) . toE qual ( 5 ) ;
} ) ;
} ) ;
/ * *
/ * *
* test _author _windy
* test _author _windy
* /
* /
it ( "others" , function ( ) {
it ( "others" , ( ) => {
expect ( BI . abc2Int ( "B" ) ) . to . equal ( 2 ) ;
expect ( BI . abc2Int ( "B" ) ) . toBe ( 2 ) ;
expect ( BI . int2Abc ( 2 ) ) . to . equal ( "B" ) ;
expect ( BI . int2Abc ( 2 ) ) . toBe ( "B" ) ;
expect ( BI . has ( { a : "1" , b : "2" } , "a" ) ) . to . equal ( true ) ;
expect ( BI . has ( { a : "1" , b : "2" } , "a" ) ) . toBe ( true ) ;
expect ( Object . isFrozen ( BI . freeze ( { a : "1" , b : "2" } ) ) ) . to . equal ( true ) ;
expect ( Object . isFrozen ( BI . freeze ( { a : "1" , b : "2" } ) ) ) . toBe ( true ) ;
expect ( BI . isCapitalEqual ( "A" , "a" ) ) . to . equal ( true ) ;
expect ( BI . isCapitalEqual ( "A" , "a" ) ) . toBe ( true ) ;
expect ( BI . isEmptyString ( "a" ) ) . to . equal ( false ) ;
expect ( BI . isEmptyString ( "a" ) ) . toBe ( false ) ;
expect ( BI . isNotEmptyString ( "a" ) ) . to . equal ( true ) ;
expect ( BI . isNotEmptyString ( "a" ) ) . toBe ( true ) ;
expect ( BI . isWindow ( "a" ) ) . to . equal ( false ) ;
expect ( BI . isWindow ( "a" ) ) . toBe ( false ) ;
} ) ;
} ) ;
/ * *
/ * *
* test _author _windy
* test _author _windy
* /
* /
it ( "deepFunc" , function ( ) {
it ( "deepFunc" , ( ) => {
expect ( BI . isDeepMatch ( { b : { c : { e : 3 } } , d : 2 } , { b : { c : { e : 3 } } , d : 2 } ) ) . to . equal ( true ) ;
expect ( BI . isDeepMatch ( { b : { c : { e : 3 } } , d : 2 } , { b : { c : { e : 3 } } , d : 2 } ) ) . toBe ( true ) ;
expect ( BI . deepIndexOf ( [ { a : 1 } , { b : 2 } , { c : 3 } ] , { c : 3 } ) ) . to . equal ( 2 ) ;
expect ( BI . deepIndexOf ( [ { a : 1 } , { b : 2 } , { c : 3 } ] , { c : 3 } ) ) . toBe ( 2 ) ;
var remove = [ { a : 1 } , { b : 2 } , { c : 3 } ] ;
var remove = [ { a : 1 } , { b : 2 } , { c : 3 } ] ;
BI . deepRemove ( remove , { c : 3 } ) ;
BI . deepRemove ( remove , { c : 3 } ) ;
expect ( remove ) . to . deep . e qual( [ { a : 1 } , { b : 2 } ] ) ;
expect ( remove ) . toE qual ( [ { a : 1 } , { b : 2 } ] ) ;
expect ( BI . deepWithout ( [ { a : 1 } , { b : 2 } , { c : 3 } ] , { c : 3 } ) ) . to . deep . e qual( [ { a : 1 } , { b : 2 } ] ) ;
expect ( BI . deepWithout ( [ { a : 1 } , { b : 2 } , { c : 3 } ] , { c : 3 } ) ) . toE qual ( [ { a : 1 } , { b : 2 } ] ) ;
expect ( BI . deepUnique ( [ { c : 3 } , { a : 1 } , { b : 2 } , { c : 3 } , { c : 3 } ] ) ) . to . deep . e qual( [ { c : 3 } , { a : 1 } , { b : 2 } ] ) ;
expect ( BI . deepUnique ( [ { c : 3 } , { a : 1 } , { b : 2 } , { c : 3 } , { c : 3 } ] ) ) . toE qual ( [ { c : 3 } , { a : 1 } , { b : 2 } ] ) ;
expect ( BI . deepDiff ( { a : 1 , b : 2 } , { a : 1 , c : 2 } ) ) . to . deep . e qual( [ "b" , "c" ] ) ;
expect ( BI . deepDiff ( { a : 1 , b : 2 } , { a : 1 , c : 2 } ) ) . toE qual ( [ "b" , "c" ] ) ;
} ) ;
} ) ;
/ * *
/ * *
* test _author _windy
* test _author _windy
* /
* /
it ( "number" , function ( ) {
it ( "number" , ( ) => {
expect ( BI . parseSafeInt ( 9007199254740992 ) ) . to . equal ( 9007199254740991 ) ;
expect ( BI . parseSafeInt ( 9007199254740992 ) ) . toBe ( 9007199254740991 ) ;
expect ( BI . isNegativeInteger ( - 3 ) ) . to . equal ( true ) ;
expect ( BI . isNegativeInteger ( - 3 ) ) . toBe ( true ) ;
expect ( BI . isFloat ( 1.2 ) ) . to . equal ( true ) ;
expect ( BI . isFloat ( 1.2 ) ) . toBe ( true ) ;
expect ( BI . isOdd ( 1 ) ) . to . equal ( true ) ;
expect ( BI . isOdd ( 1 ) ) . toBe ( true ) ;
expect ( BI . isOdd ( "a" ) ) . to . equal ( false ) ;
expect ( BI . isOdd ( "a" ) ) . toBe ( false ) ;
expect ( BI . isEven ( "a" ) ) . to . equal ( false ) ;
expect ( BI . isEven ( "a" ) ) . toBe ( false ) ;
expect ( BI . isEven ( 2 ) ) . to . equal ( true ) ;
expect ( BI . isEven ( 2 ) ) . toBe ( true ) ;
expect ( BI . sum ( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 ] ) ) . to . equal ( 28 ) ;
expect ( BI . sum ( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 ] ) ) . toBe ( 28 ) ;
expect ( BI . average ( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 ] ) ) . to . equal ( 4 ) ;
expect ( BI . average ( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 ] ) ) . toBe ( 4 ) ;
} ) ;
} ) ;
/ * *
/ * *
* test _author _windy
* test _author _windy
* /
* /
it ( "string" , function ( ) {
it ( "string" , ( ) => {
expect ( BI . toLowerCase ( "AAAAA" ) ) . to . equal ( "aaaaa" ) ;
expect ( BI . toLowerCase ( "AAAAA" ) ) . toBe ( "aaaaa" ) ;
expect ( BI . isLiteral ( "AAAAA" ) ) . to . equal ( false ) ;
expect ( BI . isLiteral ( "AAAAA" ) ) . toBe ( false ) ;
expect ( BI . stripQuotes ( "AAAAA" ) ) . to . equal ( "AAAAA" ) ;
expect ( BI . stripQuotes ( "AAAAA" ) ) . toBe ( "AAAAA" ) ;
expect ( BI . camelize ( "background-color" ) ) . to . equal ( "backgroundColor" ) ;
expect ( BI . camelize ( "background-color" ) ) . toBe ( "backgroundColor" ) ;
expect ( BI . escape ( "'\\" ) ) . to . equal ( "\\'\\\\" ) ;
expect ( BI . escape ( "'\\" ) ) . toBe ( "\\'\\\\" ) ;
expect ( BI . leftPad ( "123" , 5 , "0" ) ) . to . equal ( "00123" ) ;
expect ( BI . leftPad ( "123" , 5 , "0" ) ) . toBe ( "00123" ) ;
const cls = "my-class" , text = "Some text" ;
const cls = "my-class" , text = "Some text" ;
expect ( BI . format ( "<div class=\"{0}\">{1}</div>" , cls , text ) ) . to . equal ( "<div class=\"my-class\">Some text</div>" ) ;
expect ( BI . format ( "<div class=\"{0}\">{1}</div>" , cls , text ) ) . toBe ( "<div class=\"my-class\">Some text</div>" ) ;
} ) ;
} ) ;
/ * *
/ * *
* test _author _kobi
* test _author _kobi
* * /
* * /
it ( "checkDateVoid" , function ( ) {
it ( "checkDateVoid" , ( ) => {
const minDate = "1900-02-02" ;
const minDate = "1900-02-02" ;
const maxDate = "2099-11-29" ;
const maxDate = "2099-11-29" ;
expect ( BI . checkDateVoid ( 1899 , 2 , 2 , minDate , maxDate ) ) . to . eq l( [ "y" ] ) ;
expect ( BI . checkDateVoid ( 1899 , 2 , 2 , minDate , maxDate ) ) . toEqua l ( [ "y" ] ) ;
expect ( BI . checkDateVoid ( 2100 , 2 , 2 , minDate , maxDate ) ) . to . eq l( [ "y" , 1 ] ) ;
expect ( BI . checkDateVoid ( 2100 , 2 , 2 , minDate , maxDate ) ) . toEqua l ( [ "y" , 1 ] ) ;
expect ( BI . checkDateVoid ( 1900 , 1 , 2 , minDate , maxDate ) ) . to . eq l( [ "m" ] ) ;
expect ( BI . checkDateVoid ( 1900 , 1 , 2 , minDate , maxDate ) ) . toEqua l ( [ "m" ] ) ;
expect ( BI . checkDateVoid ( 2099 , 12 , 2 , minDate , maxDate ) ) . to . eq l( [ "m" , 1 ] ) ;
expect ( BI . checkDateVoid ( 2099 , 12 , 2 , minDate , maxDate ) ) . toEqua l ( [ "m" , 1 ] ) ;
expect ( BI . checkDateVoid ( 1900 , 2 , 1 , minDate , maxDate ) ) . to . eq l( [ "d" ] ) ;
expect ( BI . checkDateVoid ( 1900 , 2 , 1 , minDate , maxDate ) ) . toEqua l ( [ "d" ] ) ;
expect ( BI . checkDateVoid ( 2099 , 11 , 30 , minDate , maxDate ) ) . to . eq l( [ "d" , 1 ] ) ;
expect ( BI . checkDateVoid ( 2099 , 11 , 30 , minDate , maxDate ) ) . toEqua l ( [ "d" , 1 ] ) ;
} ) ;
} ) ;
/ * *
/ * *
* test _author _kobi
* test _author _kobi
* * /
* * /
it ( "parseDateTime" , function ( ) {
it ( "parseDateTime" , ( ) => {
expect ( BI . parseDateTime ( "19971109" , "%y%x%d" ) ) . to . eq l( BI . getDate ( 1997 , 10 , 9 ) ) ;
expect ( BI . parseDateTime ( "19971109" , "%y%x%d" ) ) . toEqua l ( BI . getDate ( 1997 , 10 , 9 ) ) ;
expect ( BI . parseDateTime ( "12:34:56" , "%H:%M:%S" ) ) . to . eq l( BI . getDate ( 1935 , 0 , 25 , 12 , 34 , 56 ) ) ;
expect ( BI . parseDateTime ( "12:34:56" , "%H:%M:%S" ) ) . toEqua l ( BI . getDate ( 1935 , 0 , 25 , 12 , 34 , 56 ) ) ;
expect ( BI . parseDateTime ( "1997-11-09 3:23:23 pm" , "%y-%x-%d %H:%M:%S %P" ) ) . to . eq l( BI . getDate ( 1997 , 10 , 9 , 15 , 23 , 23 ) ) ;
expect ( BI . parseDateTime ( "1997-11-09 3:23:23 pm" , "%y-%x-%d %H:%M:%S %P" ) ) . toEqua l ( BI . getDate ( 1997 , 10 , 9 , 15 , 23 , 23 ) ) ;
expect ( BI . parseDateTime ( "1997-11-09 15:23:23 am" , "%y-%x-%d %H:%M:%S %P" ) ) . to . eq l( BI . getDate ( 1997 , 10 , 9 , 3 , 23 , 23 ) ) ;
expect ( BI . parseDateTime ( "1997-11-09 15:23:23 am" , "%y-%x-%d %H:%M:%S %P" ) ) . toEqua l ( BI . getDate ( 1997 , 10 , 9 , 3 , 23 , 23 ) ) ;
expect ( BI . parseDateTime ( "a-b-c d:e:f" , "%y-%x-%d %H:%M:%S" ) . toString ( ) ) . to . eq l( BI . getDate ( ) . toString ( ) ) ;
expect ( BI . parseDateTime ( "a-b-c d:e:f" , "%y-%x-%d %H:%M:%S" ) . toString ( ) ) . toEqua l ( BI . getDate ( ) . toString ( ) ) ;
} ) ;
} ) ;
/ * *
/ * *
* test _author _kobi
* test _author _kobi
* * /
* * /
it ( "getDate 和 getTime" , function ( ) {
it ( "getDate 和 getTime" , ( ) => {
expect ( BI . getDate ( ) . toString ( ) ) . to . eq l( new Date ( ) . toString ( ) ) ;
expect ( BI . getDate ( ) . toString ( ) ) . toEqua l ( new Date ( ) . toString ( ) ) ;
expect ( BI . getDate ( 1997 ) ) . to . eq l( new Date ( 1997 ) ) ;
expect ( BI . getDate ( 1997 ) ) . toEqua l ( new Date ( 1997 ) ) ;
expect ( BI . getDate ( 1997 , 10 ) ) . to . eq l( new Date ( 1997 , 10 ) ) ;
expect ( BI . getDate ( 1997 , 10 ) ) . toEqua l ( new Date ( 1997 , 10 ) ) ;
expect ( BI . getDate ( 1997 , 10 , 9 ) ) . to . eq l( new Date ( 1997 , 10 , 9 ) ) ;
expect ( BI . getDate ( 1997 , 10 , 9 ) ) . toEqua l ( new Date ( 1997 , 10 , 9 ) ) ;
expect ( BI . getDate ( 1997 , 10 , 9 , 12 ) ) . to . eq l( new Date ( 1997 , 10 , 9 , 12 ) ) ;
expect ( BI . getDate ( 1997 , 10 , 9 , 12 ) ) . toEqua l ( new Date ( 1997 , 10 , 9 , 12 ) ) ;
expect ( BI . getDate ( 1997 , 10 , 9 , 12 , 34 ) ) . to . eq l( new Date ( 1997 , 10 , 9 , 12 , 34 ) ) ;
expect ( BI . getDate ( 1997 , 10 , 9 , 12 , 34 ) ) . toEqua l ( new Date ( 1997 , 10 , 9 , 12 , 34 ) ) ;
expect ( BI . getDate ( 1997 , 10 , 9 , 12 , 34 , 56 ) ) . to . eq l( new Date ( 1997 , 10 , 9 , 12 , 34 , 56 ) ) ;
expect ( BI . getDate ( 1997 , 10 , 9 , 12 , 34 , 56 ) ) . toEqua l ( new Date ( 1997 , 10 , 9 , 12 , 34 , 56 ) ) ;
expect ( BI . getDate ( 1997 , 10 , 9 , 12 , 34 , 56 , 78 ) ) . to . eq l( new Date ( 1997 , 10 , 9 , 12 , 34 , 56 , 78 ) ) ;
expect ( BI . getDate ( 1997 , 10 , 9 , 12 , 34 , 56 , 78 ) ) . toEqua l ( new Date ( 1997 , 10 , 9 , 12 , 34 , 56 , 78 ) ) ;
expect ( BI . getTime ( ) ) . to . eq l( new Date ( ) . getTime ( ) ) ;
expect ( BI . getTime ( ) ) . toEqua l ( new Date ( ) . getTime ( ) ) ;
expect ( BI . getTime ( 1997 ) ) . to . eq l( new Date ( 1997 ) . getTime ( ) ) ;
expect ( BI . getTime ( 1997 ) ) . toEqua l ( new Date ( 1997 ) . getTime ( ) ) ;
expect ( BI . getTime ( 1997 , 10 ) ) . to . eq l( new Date ( 1997 , 10 ) . getTime ( ) ) ;
expect ( BI . getTime ( 1997 , 10 ) ) . toEqua l ( new Date ( 1997 , 10 ) . getTime ( ) ) ;
expect ( BI . getTime ( 1997 , 10 , 9 ) ) . to . eq l( new Date ( 1997 , 10 , 9 ) . getTime ( ) ) ;
expect ( BI . getTime ( 1997 , 10 , 9 ) ) . toEqua l ( new Date ( 1997 , 10 , 9 ) . getTime ( ) ) ;
expect ( BI . getTime ( 1997 , 10 , 9 , 12 ) ) . to . eq l( new Date ( 1997 , 10 , 9 , 12 ) . getTime ( ) ) ;
expect ( BI . getTime ( 1997 , 10 , 9 , 12 ) ) . toEqua l ( new Date ( 1997 , 10 , 9 , 12 ) . getTime ( ) ) ;
expect ( BI . getTime ( 1997 , 10 , 9 , 12 , 34 ) ) . to . eq l( new Date ( 1997 , 10 , 9 , 12 , 34 ) . getTime ( ) ) ;
expect ( BI . getTime ( 1997 , 10 , 9 , 12 , 34 ) ) . toEqua l ( new Date ( 1997 , 10 , 9 , 12 , 34 ) . getTime ( ) ) ;
expect ( BI . getTime ( 1997 , 10 , 9 , 12 , 34 , 56 ) ) . to . eq l( new Date ( 1997 , 10 , 9 , 12 , 34 , 56 ) . getTime ( ) ) ;
expect ( BI . getTime ( 1997 , 10 , 9 , 12 , 34 , 56 ) ) . toEqua l ( new Date ( 1997 , 10 , 9 , 12 , 34 , 56 ) . getTime ( ) ) ;
expect ( BI . getTime ( 1997 , 10 , 9 , 12 , 34 , 56 , 78 ) ) . to . eq l( new Date ( 1997 , 10 , 9 , 12 , 34 , 56 , 78 ) . getTime ( ) ) ;
expect ( BI . getTime ( 1997 , 10 , 9 , 12 , 34 , 56 , 78 ) ) . toEqua l ( new Date ( 1997 , 10 , 9 , 12 , 34 , 56 , 78 ) . getTime ( ) ) ;
} ) ;
} ) ;
/ * *
/ * *
* test _author _kobi
* test _author _kobi
* * /
* * /
it ( "数字相关方法补充" , function ( ) {
it ( "数字相关方法补充" , ( ) => {
const iteratee = function ( a , b ) {
const iteratee = function ( a , b ) {
return a > b ? a : b ;
return a > b ? a : b ;
} ;
} ;
expect ( BI . isNaturalNumber ( 1.25 ) ) . to . eq l( false ) ;
expect ( BI . isNaturalNumber ( 1.25 ) ) . toEqua l ( false ) ;
expect ( BI . isPositiveInteger ( - 15 ) ) . to . eq l( false ) ;
expect ( BI . isPositiveInteger ( - 15 ) ) . toEqua l ( false ) ;
expect ( BI . isNegativeInteger ( + 15 ) ) . to . eq l( false ) ;
expect ( BI . isNegativeInteger ( + 15 ) ) . toEqua l ( false ) ;
expect ( BI . isFloat ( 15 ) ) . to . eq l( false ) ;
expect ( BI . isFloat ( 15 ) ) . toEqua l ( false ) ;
expect ( BI . sum ( [ 4 , 3 , 2 , 1 ] , iteratee ) ) . to . eq l( 12 ) ;
expect ( BI . sum ( [ 4 , 3 , 2 , 1 ] , iteratee ) ) . toEqua l ( 12 ) ;
} ) ;
} ) ;
/ * *
/ * *
* test _author _kobi
* test _author _kobi
* * /
* * /
it ( "集合相关方法补充" , function ( ) {
it ( "集合相关方法补充" , ( ) => {
const array = [ {
const array = [ {
user : "barney" ,
user : "barney" ,
active : true ,
active : true ,
@ -383,39 +383,39 @@ describe("baseFunctionTest", function () {
user : "pebbles" ,
user : "pebbles" ,
active : false ,
active : false ,
} ] ;
} ] ;
expect ( BI . backEvery ( array , ( index , value ) => value . user === "kobi" ) ) . to . eq l( false ) ;
expect ( BI . backEvery ( array , ( index , value ) => value . user === "kobi" ) ) . toEqua l ( false ) ;
expect ( BI . backFind ( array , [ "active" , false ] ) ) . to . eq l( array [ 2 ] ) ;
expect ( BI . backFind ( array , [ "active" , false ] ) ) . toEqua l ( array [ 2 ] ) ;
expect ( BI . abc2Int ( "ABCD999" ) ) . to . eq l( 0 ) ;
expect ( BI . abc2Int ( "ABCD999" ) ) . toEqua l ( 0 ) ;
expect ( BI . int2Abc ( 0 ) ) . to . eq l( "" ) ;
expect ( BI . int2Abc ( 0 ) ) . toEqua l ( "" ) ;
expect ( BI . int2Abc ( 26 ) ) . to . eq l( "Z" ) ;
expect ( BI . int2Abc ( 26 ) ) . toEqua l ( "Z" ) ;
} ) ;
} ) ;
/ * *
/ * *
* test _author _kobi
* test _author _kobi
* * /
* * /
it ( "数组相关方法补充" , function ( ) {
it ( "数组相关方法补充" , ( ) => {
expect ( BI . makeArrayByArray ( [ ] , 5 ) ) . to . eq l( [ ] ) ;
expect ( BI . makeArrayByArray ( [ ] , 5 ) ) . toEqua l ( [ ] ) ;
expect ( BI . uniq ( null , true , ( a , b ) => a > b ) ) . to . eq l( [ ] ) ;
expect ( BI . uniq ( null , true , ( a , b ) => a > b ) ) . toEqua l ( [ ] ) ;
} ) ;
} ) ;
/ * *
/ * *
* test _author _kobi
* test _author _kobi
* * /
* * /
it ( "对象相关方法补充" , function ( ) {
it ( "对象相关方法补充" , ( ) => {
var obj = {
var obj = {
a : 1 ,
a : 1 ,
b : 2 ,
b : 2 ,
c : 3 ,
c : 3 ,
} ;
} ;
expect ( BI . has ( obj , [ ] ) ) . to . eq l( false ) ;
expect ( BI . has ( obj , [ ] ) ) . toEqua l ( false ) ;
expect ( BI . has ( obj , [ "a" , "b" ] ) ) . to . eq l( true ) ;
expect ( BI . has ( obj , [ "a" , "b" ] ) ) . toEqua l ( true ) ;
expect ( BI . freeze ( "1" ) ) . to . eq l( "1" ) ;
expect ( BI . freeze ( "1" ) ) . toEqua l ( "1" ) ;
} ) ;
} ) ;
/ * *
/ * *
* test _author _kobi
* test _author _kobi
* * /
* * /
it ( "deep方法补充" , function ( ) {
it ( "deep方法补充" , ( ) => {
var obj = {
var obj = {
a : 1 ,
a : 1 ,
b : 2 ,
b : 2 ,
@ -426,19 +426,19 @@ describe("baseFunctionTest", function () {
} ,
} ,
} ,
} ,
} ;
} ;
expect ( BI . isDeepMatch ( null , { d : 3 , e : { f : 4 } } ) ) . to . eq l( false ) ;
expect ( BI . isDeepMatch ( null , { d : 3 , e : { f : 4 } } ) ) . toEqua l ( false ) ;
expect ( BI . isDeepMatch ( obj , { d : 3 , e : { f : 5 } } ) ) . to . eq l( false ) ;
expect ( BI . isDeepMatch ( obj , { d : 3 , e : { f : 5 } } ) ) . toEqua l ( false ) ;
expect ( BI . deepIndexOf ( obj , { d : 3 , e : { f : 5 } } ) ) . to . eq l( - 1 ) ;
expect ( BI . deepIndexOf ( obj , { d : 3 , e : { f : 5 } } ) ) . toEqua l ( - 1 ) ;
expect ( BI . deepRemove ( obj , { d : 3 , e : { f : 4 } } ) ) . to . eq l( true ) ;
expect ( BI . deepRemove ( obj , { d : 3 , e : { f : 4 } } ) ) . toEqua l ( true ) ;
expect ( BI . deepWithout ( obj , { d : 3 , e : { f : 4 } } ) ) . to . eq l( { a : 1 , b : 2 } ) ;
expect ( BI . deepWithout ( obj , { d : 3 , e : { f : 4 } } ) ) . toEqua l ( { a : 1 , b : 2 } ) ;
} ) ;
} ) ;
/ * *
/ * *
* test _author _teller
* test _author _teller
* 只传一个时分秒format的时间进去后 , 在某些情况下 , 返回的是当前时间 , 然而想要的是返回正确的时分秒
* 只传一个时分秒format的时间进去后 , 在某些情况下 , 返回的是当前时间 , 然而想要的是返回正确的时分秒
* /
* /
it ( "parseDateTime2" , function ( ) {
it ( "parseDateTime2" , ( ) => {
var date = BI . getDate ( ) ;
var date = BI . getDate ( ) ;
expect ( BI . parseDateTime ( "14:13:16" , "%H:%M:%S" ) . getTime ( ) ) . to . eq l( BI . getDate ( date . getFullYear ( ) , date . getMonth ( ) , 14 , 14 , 13 , 16 ) . getTime ( ) ) ;
expect ( BI . parseDateTime ( "14:13:16" , "%H:%M:%S" ) . getTime ( ) ) . toEqua l ( BI . getDate ( date . getFullYear ( ) , date . getMonth ( ) , 14 , 14 , 13 , 16 ) . getTime ( ) ) ;
} ) ;
} ) ;
} ) ;
} ) ;