all files / src/Test/ index.js

30% Statements 3/10
27.27% Branches 3/11
40% Functions 2/5
30% Lines 3/10
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                                                             
import {empty, isArray} from "../Type";
 
export function testArray(array){
  Iif(!isArray(array)){
    throw new Error('请传入数组')
  }
}
 
export function testInclude(value,array){
  Iif(!isArray(array)){
    throw new Error('请传入需包含的区间数组')
  }
  Iif(!array.includes(value)){
    throw new Error('不在可选参数范围,'+array.toString())
  }
}
 
export function testDateFormat(value){
  testInclude(value,
['YYYY-MM-DD hh:mm:ss', 'YYYY/MM/DD hh:mm:ss',
      'YYYY-MM-DD', 'YYYY/MM/DD',
      'MM-DD', 'MM/DD', 'hh:mm:ss', 'hh:mm',
      'computed', 'timeAgo'
  ])
}
export function testLang(value){
  testInclude(value,['zh-CN','en-US'])
}
export function testTimeZone(value){
  if(empty(value) || parseInt(value)>12 || parseInt(value)<-12){
    throw new Error('传入时区有误,请传入 -12 ~ 12 之间的数字')
  }
}