Skip to content

tools.js

Carl's edited this page May 31, 2021 · 11 revisions

tools.js 函数测试用例

getIndexInArray

  • 传递参数:
  • 参数1:"abcdef"
  • 参数2:"b"
  • 返回:
[{index:"1",text:"b"}]

getPingMatchObjKey

  • params:
    • params1: ”nihaoma“
    • params2:来之zh.js文件的zhKeysArray格式如:
        ["chuang", "shuang", "zhuang", "chang", "cheng", "chong", "chuai"]
  • return:
       [
        {
          index: 0
          key: "ni"
        },
        {
          index: 2
          key: "hao"
        },
        {
         index: 5
         key: "ma"
        },
       ]

getFullPingMatchObjKey

case 1:

  • params:
    • params1: ”nihao“
    • params2:来之本地localstorage 格式如:
        ["__$lastClearTime","nihao"]
  • return :
       [
        {
         index: 0
         key: "nihao"
        }
       ]

case2:

  • params:
    • params1: ”nihao“
    • params2:来之本地localstorage 格式如:
        ["__$lastClearTime"]
  • return:
       []
    
    ```

wrapStringSingleItem

  • params: "你"
  • return:
 `<span class="vue-keyboard-text-item"  tabindex="0">你</span>`

splitStringToArray

case1

  • params:"1"
  • return:
 [`<span class="vue-keyboard-text-item"  tabindex="0">1</span>`]

case2

  • params:
 4<img attr-img=""vue-keyboard-cn-emoji" class=" emoji-icon icon-wink" src="https://raw.githubusercontent.com/MTTTM/vue-keyboard-cn/main/src/dev/assets/images//person/6_wink.png" />1
  • return:
   [
    '<span class="vue-keyboard-text-item"  tabindex="0">4</span>',
    '<img attr-img=""vue-keyboard-cn-emoji" class=" emoji-icon icon-wink" src="https://raw.githubusercontent.com/MTTTM/vue-keyboard-cn/main/src/dev/assets/images//person/6_wink.png" />',
  '<span class="vue-keyboard-text-item"  tabindex="0">1</span>'

]

case 3

  • params:"0\r\n2"
  • return:
   [
      '<span class="vue-keyboard-text-item"  tabindex="0">0</span>',
     '<br/>',
     '<span class="vue-keyboard-text-item"  tabindex="0">2</span>'
  ]
  

getElementIndexOnParent

  • case:
let createChild=function(elementName="p"){
    let t=document.createElement("div");
    wrap.appendChild(t);
}
createChild("p");
createChild("p");
createChild("p");
createChild("div");
document.body.appendChild(wrap)
  • params: HTML DOM Div Object
  • return 3

labelStringRemoveLabelExceptImg

case 1

  • params :
<span class="vue-keyboard-text-item"  tabindex="0">0</span>
  • return :0

case 2:

  • params:
<img attr-img=""vue-keyboard-cn-emoji" class=" emoji-icon icon-blush" src="https://raw.githubusercontent.com/MTTTM/vue-keyboard-cn/main/src/dev/assets/images//person/4_blush.png" />
  • return
<img attr-img=""vue-keyboard-cn-emoji" class=" emoji-icon icon-blush" src="https://raw.githubusercontent.com/MTTTM/vue-keyboard-cn/main/src/dev/assets/images//person/4_blush.png" />

case 3:

  • params:
 <br/>
  • return:" "

uuid

  • case:
  let arr=Array.from(new Array(100).keys()).fill(uuid());//create an array length is 100 and fill it uuid();
  retun new Set(arr).size === arr.length
  • return :true